Environment variables

Set HTTPS_PROXY, HTTP_PROXY, ALL_PROXY and NO_PROXY for NyxonProxies on Linux, macOS and Windows, and learn which tools read them and which patterns work.

Most command-line tools and HTTP libraries can take the proxy from environment variables. Set them once and every tool in that shell uses NyxonProxies, with no change to your code. The catch is that tools disagree on the details, so this page sticks to settings that work everywhere.

The variables

VariableUsed for
HTTPS_PROXYRequests to https:// URLs
HTTP_PROXYRequests to http:// URLs
ALL_PROXYA fallback for any scheme, read by some tools only
NO_PROXYHosts that skip the proxy, separated by commas

The value is the address of the gateway. For the HTTP port it starts with http://, even in HTTPS_PROXY: the client asks the gateway for a tunnel and runs TLS to the site inside it. Writing https:// there makes the client try TLS with the gateway itself, which fails.

Linux and macOS

bash
export https_proxy="http://USERNAME:[email protected]:8080"
export HTTPS_PROXY="$https_proxy"
export http_proxy="$https_proxy"
export HTTP_PROXY="$https_proxy"
export no_proxy="localhost,127.0.0.1,::1"
export NO_PROXY="$no_proxy"
curl https://api.ipify.org

Tools disagree on whether the upper-case or the lower-case name wins, so set both to the same value. Add the lines to ~/.bashrc or ~/.zshrc to keep them for new shells.

Windows

In PowerShell, for the current window:

powershell
$env:HTTPS_PROXY = "http://USERNAME:[email protected]:8080"
$env:HTTP_PROXY = $env:HTTPS_PROXY
curl.exe https://api.ipify.org

In Command Prompt, for the current window:

bat
set HTTPS_PROXY=http://USERNAME:[email protected]:8080
set HTTP_PROXY=%HTTPS_PROXY%
curl https://api.ipify.org

Windows ignores the case of variable names, so one of each is enough. To keep a variable for future windows, use setx. It does not change the window you run it in:

bat
setx HTTPS_PROXY "http://USERNAME:[email protected]:8080"

Which tools read them

ToolReads the variables
curlYes
Python Requests, HTTPX and urllibYes
Python aiohttpOnly with trust_env=True
Node.js fetch and httpsOnly with NODE_USE_ENV_PROXY=1 or --use-env-proxy
axiosYes
Go net/httpYes, through the default client
git, pip, npmYes

Browsers use their own or the system proxy settings instead. See the guides under Browsers and devices in the sidebar.

Rules that work everywhere

  • Always set HTTPS_PROXY. With only HTTP_PROXY set, most clients send requests to HTTPS sites directly, from your own IP.
  • Do not rely on ALL_PROXY. curl, Requests, HTTPX and git use it; aiohttp, urllib, Node.js and Go ignore it.
  • Write NO_PROXY domains with a leading dot. .example.com works in every client. *.example.com is ignored by most of them.
  • List local addresses one by one. localhost does not cover 127.0.0.1, and ranges such as 127.0.0.0/8 work in some tools only. Use localhost,127.0.0.1,::1.
  • Remember the lower case for curl. curl reads http_proxy only in lower case.
  • Percent-encode special characters in the password, such as @ as %40, or change the proxy password.

Tools with their own setting

Some tools also have a setting of their own, handy when only one tool should use the proxy.

git, with Basic authentication sent straight away:

bash
git config --global http.proxy http://USERNAME:[email protected]:8080
git config --global http.proxyAuthMethod basic

git config --global --unset http.proxy removes the setting again.

pip, for one command:

bash
pip install --proxy http://USERNAME:[email protected]:8080 requests

npm:

bash
npm config set https-proxy http://USERNAME:[email protected]:8080

Check that it works

A skipped proxy fails silently: the request just leaves from your own IP. After any change, run curl https://api.ipify.org in the same shell and check that the address is not yours.

Last updated

Still stuck?

People answer the live chat around the clock. Send the proxy line you used (without the password) and the error you see.