# curl through a proxy: -x, environment variables, SOCKS and no_proxy

Source: https://checkcraft.ru/en/guides/curl-proxy.html · updated 2026-12-02

How to send a curl request through a proxy: -x and --proxy, proxy login and password, SOCKS5, the http_proxy, https_proxy and no_proxy variables…

Practical workflow

Checkcraft is a desktop app for checking APIs and logs without code, with a free edition. [Download, no sign-up →](https://checkcraft.ru/en/download-checkcraft.html#free-download)

In a corporate network requests often go through a proxy and curl must know about it. The proxy is set with -x or environment variables, and internal addresses are excluded with no_proxy. Below are commands and the usual errors when curl cannot connect through the proxy or uses it when it should not.

Checkcraft · 24 November 2026

Get help with your first test →

## The -x flag and environment variables

-x host:port sets a proxy for one request. To avoid typing it every time, set http_proxy and https_proxy. For addresses that must go direct, such as internal services and localhost, fill no_proxy with a comma-separated list.

## SOCKS5 and auth

For SOCKS5 put the scheme in the proxy URL: socks5h:// resolves names on the proxy side, socks5:// locally. Proxy login and password go with -U or in the proxy URL. Encode special characters in the password or curl misparses the URL.

Repeating checks like this by hand? Checkcraft saves them and reruns them in one click. [Download Free →](https://checkcraft.ru/en/download-checkcraft.html#free-download)

## When the proxy gets in the way

If an internal service fails while outside sites work, the request probably went to the proxy from environment variables. Check with -v which address curl connects to, and add the service to no_proxy or disable the proxy for the request with --noproxy and an asterisk.

## Proxy commands

```
# прокси для одного запроса
curl -x http://proxy.corp.local:3128 https://api.example.com/health

# прокси с логином и паролем
curl -x http://proxy.corp.local:3128 -U "ivan:пароль" https://api.example.com/health

# SOCKS5, имена резолвит прокси
curl -x socks5h://127.0.0.1:1080 https://api.example.com/health

# переменные окружения (Linux, macOS)
export https_proxy=http://proxy.corp.local:3128
export http_proxy=http://proxy.corp.local:3128
export no_proxy=localhost,127.0.0.1,.corp.local

# не использовать прокси для этого запроса
curl --noproxy "*" http://erp.corp.local/health
```

On Windows set variables with set in cmd or $env: in PowerShell. Case matters for http_proxy: curl reads it only in lowercase.

## Errors through a proxy

| Symptom | What to check |
|---|---|
| 407 Proxy Authentication Required | Proxy login and password, -U |
| Could not resolve proxy | Proxy address, DNS, a typo in the variable |
| Internal service does not open | no_proxy; the request went to the proxy |
| SSL certificate problem | The proxy intercepts TLS; pass the corporate root with --cacert |

## More on curl

Section overview and all guides: [curl command cheat sheet: flags and examples for APIs](https://checkcraft.ru/en/guides/curl-cheat-sheet.html).

- [PHP cURL: GET and POST requests with JSON, headers and error handling](https://checkcraft.ru/en/guides/php-curl.html)
- [Webhook: what it is, how it works and how to test it](https://checkcraft.ru/en/guides/webhook-testing.html)
- [curl GET request: parameters, response headers and status code](https://checkcraft.ru/en/guides/curl-get-request.html)
- [cURL examples: GET and POST requests with JSON on Linux, Windows and PowerShell](https://checkcraft.ru/en/guides/curl-post-json.html)
- [Headers in curl: Content-Type application/json, Accept and multiple -H](https://checkcraft.ru/en/guides/curl-headers-content-type.html)

Next step

## Repeat this on your own API

Checkcraft is a desktop app that saves API response checks without code and shows what did not match. Start with a sample, then use your own sanitized data. Free runs on Windows and Linux with no time limit.

[Download Free](https://checkcraft.ru/en/download-checkcraft.html#free-download) · [Download and first run](https://checkcraft.ru/en/download-checkcraft.html)

No sign-up or email needed, the archive is ready in a couple of minutes. See the [edition limits](https://checkcraft.ru/en/pricing.html).

## References

[curl man page](https://curl.se/docs/manpage.html)

## Continue with a related task

[curl errors: codes 6, 7, 22, 28, 35, 60 and how to fix them](https://checkcraft.ru/en/guides/curl-errors.html) · [curl GET request: parameters, response headers and status code](https://checkcraft.ru/en/guides/curl-get-request.html) · [Download a file with curl: -o, -O, redirects and resume](https://checkcraft.ru/en/guides/curl-download-file.html) · [curl on Windows and PowerShell: how to run it and why commands fail](https://checkcraft.ru/en/guides/curl-windows-powershell.html)

Start with the linked example and compare its result with your own test requirement.

Ask a person

## Get help with your first test

Tell us what you want to test or where you got stuck. We can help you start Checkcraft, choose an example and understand your first run. You can ask before downloading.

[Ask in Telegram](https://t.me/checkcraftchat)Send an email

The Telegram group is public: do not post passwords, tokens or confidential work data. A description of your task is enough to start.

You can also email us support@checkcraft.ru

Page card: /ai/pages/en/guides/curl-proxy.md
