HTTP_PROXY, HTTPS_PROXY and NO_PROXY: Why a Program Ignores the Proxy
Environment variables are the easiest way to give a proxy to many programs at once. But each program reads them in its own way, and some do not read them at all.
Updated · Prokso editorial team
- HTTPS_PROXY refers to the type of address you open, so its value usually starts with http://
- Programs read the variables differently: curl takes http_proxy only in lowercase, Node.js only with a flag
- Docker, git and pip have their own proxy settings, and the variables must reach the process itself
What the error means
HTTP_PROXY sets the proxy for http:// addresses, HTTPS_PROXY for https:// addresses, ALL_PROXY for everything without its own variable, and NO_PROXY lists hosts to reach directly. This is a convention, not a standard, so support differs between tools.
The name HTTPS_PROXY refers to the type of address you open, not to the protocol of the proxy itself. That is why the value usually starts with http://: the program talks to the proxy over plain HTTP, asks it to open a CONNECT tunnel and sets up TLS with the site inside it. For Prokso both variables can point to http://USERNAME:PASSWORD@gw.prokso.com:823.
Case matters too. curl reads most variables in either case, but http_proxy only in lowercase. Python requests and Node.js accept both, and in Node.js the lowercase form wins when both are set.
Causes
- Node.js without the flag. According to its documentation, Node.js reads HTTP_PROXY, HTTPS_PROXY and NO_PROXY only with NODE_USE_ENV_PROXY=1 or --use-env-proxy. ALL_PROXY is not on that list.
- Uppercase HTTP_PROXY in curl. curl accepts only lowercase http_proxy, so an uppercase variable does not work for http:// addresses.
- The host is in NO_PROXY. If the address matches NO_PROXY, the program goes direct. curl applies NO_PROXY even to a proxy set with --proxy.
- The variables did not reach the process. They were set in another terminal, not exported, or the program runs as a service or through sudo, which resets the environment by default.
- The program has its own settings. Docker, git and pip have their own proxy settings that work separately from the variables or take priority over them.
How to fix it
- Set the variables in both cases:
export http_proxy=http://USERNAME:PASSWORD@gw.prokso.com:823, then the same for HTTP_PROXY, https_proxy and HTTPS_PROXY. Examples for curl are in the curl guide. - For SOCKS5 in curl and Python requests you can set
ALL_PROXY=socks5h://USERNAME:PASSWORD@gw.prokso.com:824. requests needsrequests[socks]installed for SOCKS; details are in the Python requests guide. - In Node.js, start the program with
NODE_USE_ENV_PROXY=1or--use-env-proxyif your version supports it, or connect an agent in code as in the Node.js guide. - For pip, use the http_proxy and https_proxy variables or, more reliably, the
--proxyoption. git reads http_proxy, https_proxy and all_proxy, and thehttp.proxysetting in git config overrides them. - In Docker, keep two cases apart. The proxy for containers and builds goes into ~/.docker/config.json under proxies, and Docker passes the variables in both cases. The proxy for pulling images is set separately for the daemon, in daemon.json or in the docker service variables.
- If the password has special characters, URL-encode it, or turn on IP access in the dashboard (up to 5 addresses per plan) if that is easier. The username syntax is on the username, ports and parameters page.
How to check that it works
Run curl https://prokso.com/ip in the same terminal without -x. If the response shows the proxy IP and country, the variables work. Your own address without the proxy is shown by the my IP check, and if something does not add up, go through the step-by-step check.
Two-minute diagnosis
First paste the line into the proxy checker. If the proxy works there, the cause is in your app or its settings. If not, test the line from a terminal:
curl -v -x "http://USERNAME:PASSWORD@gw.prokso.com:823" https://api.ipify.org
- A
< HTTP/1.1 407line right afterCONNECTmeans the proxy answered. The name after the code, for exampleNO_USER, points to the cause. - The proxy answered
CONNECTwith 200 and then another code arrived - the proxy works, and that answer came from the website. - No answer at all, only a timeout - the connection never reached the proxy: check the host, port and network.
Setup guides where this error comes up
FAQ
Can I write https:// in HTTPS_PROXY?
Only if the proxy itself accepts TLS connections. Port 823 is an HTTP proxy, so for Prokso write http://, and HTTPS sites still go through an encrypted tunnel.
Why add localhost to NO_PROXY?
So that requests to local services do not go through the proxy and do not use traffic. curl, requests and Node.js accept a comma-separated list of hosts in NO_PROXY.
Does Docker use my terminal variables for docker pull?
The Docker documentation describes the daemon proxy separately: daemon.json or the service variables. Docker Desktop has its own proxy settings.
Other proxy errors
Residential $1.59, mobile $2.50, datacenter $0.65 per GB
Sign up in a minute, get access right after payment.