Skip to content
Proxy fundamentals

How no_proxy and http_proxy work in curl, Python, Go, Node

http_proxy, https_proxy and no_proxy tested in 12 client setups: the uppercase rule, leading dots, CIDR and wildcards that each client reads differently.

On this page 11 sections
  1. The four variables
  2. Uppercase or lowercase: what each client reads
  3. Why HTTP_PROXY is special
  4. no_proxy: the same string, different routing
  5. What the differences mean in practice
  6. Node: the flag, and one difference on the wire
  7. Proving which variable actually applied
  8. Where the variables do not reach
  9. Troubleshooting
  10. When environment variables are the wrong tool
  11. How this was tested

Set the lowercase names, list both the apex and the dotted form in no_proxy, and never rely on a CIDR range or a *. wildcard unless you know which client will read it. That is the portable setting. The variables have no specification, so every client wrote its own parser. We ran 12 client configurations against a logging proxy and the same no_proxy string routed differently depending on who read it. curl and wget ignore uppercase HTTP_PROXY. Go ignores a leading-dot entry for the apex domain. Python’s urllib never matches 10.0.0.0/8. Node’s fetch ignores all of it unless you start Node with NODE_USE_ENV_PROXY=1.

# The portable form: lowercase, apex and subdomains listed separately, addresses not ranges
export http_proxy="http://gw.example.net:8000"
export https_proxy="http://gw.example.net:8000"
export no_proxy="localhost,127.0.0.1,internal.example,.internal.example"

# Uppercase copies are harmless for every client tested, and some tools only read them
export HTTPS_PROXY="$https_proxy" NO_PROXY="$no_proxy"

The four variables

Variable Applies to Notes
http_proxy Requests to http:// URLs The one variable with a case rule; see below
https_proxy Requests to https:// URLs The proxy that receives the CONNECT for the tunnel
all_proxy Any scheme with no more specific variable curl reads it; Go’s httpproxy package does not
no_proxy Exemptions from all of the above Comma-separated; matching rules differ per client

The value has the same form as curl’s -x argument: scheme://host:port, with optional inline credentials. Credentials placed here are readable by every process that can read the environment, and by anything that prints it. curl’s own verbose mode does exactly that:

$ https_proxy=http://user:pass@127.0.0.1:18763 curl -sv -o /dev/null https://example.com/
* Uses proxy env variable https_proxy == 'http://user:pass@127.0.0.1:18763'
* Connected to 127.0.0.1 (127.0.0.1) port 18763
* Proxy auth using Basic with user 'user'
* Establish HTTP proxy tunnel to example.com:443
> CONNECT example.com:443 HTTP/1.1
> Proxy-Authorization: Basic dXNlcjpwYXNz
< HTTP/1.1 200 Connection Established

The password appears in clear on the first line and in base64 on the sixth. Anyone pasting a curl -v log into a ticket is pasting their proxy credentials.

Uppercase or lowercase: what each client reads

Each cell below is one run. The proxy variable pointed at a local proxy that logs every request it receives; “Used” means the log recorded the request, “Ignored” means the request went direct and the log stayed empty. A run with no variables set confirmed every client goes direct by default.

Client http_proxy HTTP_PROXY HTTP_PROXY + REQUEST_METHOD https_proxy HTTPS_PROXY
curl 8.7.1 Used Ignored Ignored Used Used
GNU wget 1.25.0 Used Ignored Ignored Used Ignored
Python urllib (3.9.6 and 3.15.0) Used Used Ignored Used Used
requests 2.32.3 Used Used Ignored Used Used
httpx 0.27.2 Used Used Ignored Used Used
aiohttp 3.10.5, default Ignored Ignored Ignored Ignored Ignored
aiohttp 3.10.5, trust_env=True Used Used Ignored Used Used
Go 1.24.4 net/http Used Used Refused with an error Used Used
Node 24.2.0 fetch Ignored Ignored Ignored Ignored Ignored
Node 24.2.0 fetch, NODE_USE_ENV_PROXY=1 Used Used Used Used Used
Node 24.2.0 http.get, NODE_USE_ENV_PROXY=1 Ignored Ignored Ignored Ignored Ignored
axios 1.7.7 and 1.18.1 Used Used Used Used Used

Three rows surprise people. wget reads only the lowercase names, so an exported HTTPS_PROXY alone does nothing for it. aiohttp ignores the environment unless you pass trust_env=True to the session. And Node’s http module ignored the variables even with the flag on 24.2.0. Node’s documentation lists NODE_USE_ENV_PROXY as added in v24.0.0, but built-in proxy support for the http and https modules only in v24.5.0 and v22.21.0. On 24.2.0 the flag changed fetch and left http.get alone, which matches those dates. On Node 18.13.0 the flag did nothing at all.

Why HTTP_PROXY is special

In a CGI environment, every inbound request header reaches the script as an environment variable with an HTTP_ prefix. A request carrying a Proxy: header therefore arrives as HTTP_PROXY. If the HTTP client inside that script honoured it, any visitor could send the server’s outbound traffic to a host of their choosing. This was disclosed in 2016 as httpoxy, and the common fix was to stop trusting the uppercase spelling of that one name.

Clients picked different fixes, and the REQUEST_METHOD column shows them. curl and wget never read uppercase HTTP_PROXY at all. CPython, and everything built on its getproxies(), drops it only when REQUEST_METHOD is present, which it treats as proof of CGI:

$ HTTP_PROXY=http://127.0.0.1:18763 python3 -c \
    "import urllib.request as u; print(u.getproxies_environment())"
{'http': 'http://127.0.0.1:18763'}

$ REQUEST_METHOD=GET HTTP_PROXY=http://127.0.0.1:18763 python3 -c \
    "import urllib.request as u; print(u.getproxies_environment())"
{}

Go refuses loudly rather than quietly going direct:

Get "http://example.org/": refusing to use HTTP_PROXY value in CGI environment; see golang.org/s/cgihttpproxy

Node with NODE_USE_ENV_PROXY=1 and both axios versions used the uppercase value even with REQUEST_METHOD=GET set. Running Node or axios as a CGI script is rare. If you do, unset HTTP_PROXY before the HTTP client starts.

The practical rule is unchanged: set the lowercase spelling. Every client that reads the environment at all honoured it.

no_proxy: the same string, different routing

Each row sets no_proxy and NO_PROXY to the same value, with both proxy variables pointing at the logging proxy. “Bypass” means the client went direct. “Proxied” means the log recorded the request, so the exemption did not apply. The first row is the control: an empty list, and every client used the proxy.

no_proxy Host requested curl 8.7.1 wget 1.25.0 urllib 3.9 / 3.15 requests 2.32.3 httpx 0.27.2 aiohttp 3.10.5 Go 1.24.4 Node 24.2.0 fetch axios 1.7.7 / 1.18.1
(empty) example.org Proxied Proxied Proxied Proxied Proxied Proxied Proxied Proxied Proxied
.example.org api.example.org Bypass Bypass Bypass Bypass Bypass Bypass Bypass Bypass Bypass
.example.org example.org Bypass Proxied Bypass Bypass Proxied Bypass Proxied Proxied Proxied
example.org api.example.org Bypass Bypass Bypass Bypass Bypass Bypass Bypass Proxied Proxied
*.example.org api.example.org Proxied Proxied Proxied Proxied Proxied Proxied Bypass Bypass Bypass
10.0.0.0/8 10.1.2.3 Bypass Proxied Proxied Bypass Proxied Proxied Bypass Proxied Proxied
10.1.2.3 10.1.2.3 Bypass Bypass Bypass Bypass Bypass Bypass Bypass Bypass Bypass
* example.org Bypass Proxied Bypass Bypass Bypass Bypass Bypass Bypass Bypass
example.org:8080 example.org (port 80) Proxied Proxied Proxied Proxied Proxied Proxied Proxied Proxied Proxied

aiohttp was run with trust_env=True and Node with NODE_USE_ENV_PROXY=1, since neither reads the list otherwise. Bold marks the cells that differ from the majority of the row.

What the differences mean in practice

The leading dot. Go’s documentation states the rule exactly: .y.com “matches x.y.com but not y.com”. wget, httpx, Node and axios behaved the same way. curl, urllib, requests and aiohttp read .example.org as the domain and everything below it. A team that writes no_proxy=".internal.corp" and expects internal.corp to be exempt gets that in Python and the opposite in Go. Writing both forms, internal.corp,.internal.corp, removes the question.

A bare domain. example.org covered api.example.org in seven of the nine clients. Node and axios treated it as an exact host. Node’s documentation describes example.com as an “exact host name match”, so this is intended, and it is the reason to add the dotted form as well.

Wildcards. *.example.org worked only in Go, Node and axios. The curl documentation says the only wildcard it accepts is a single *, which disables the proxy entirely. That single * worked everywhere except wget 1.25.0, which went to the proxy anyway.

CIDR ranges. curl (CIDR support was added in 7.86.0), requests and Go matched 10.0.0.0/8 against 10.1.2.3. urllib, httpx, aiohttp, wget, Node and axios compared strings and sent the request to the proxy. The split inside Python is easy to miss: requests has its own CIDR check, while the standard library it sits on does not.

$ no_proxy=10.0.0.0/8 python3 -c "
import urllib.request as u, requests.utils as ru
print('urllib proxy_bypass 10.1.2.3:', bool(u.proxy_bypass_environment('10.1.2.3')))
print('requests should_bypass_proxies:', ru.should_bypass_proxies('http://10.1.2.3/', no_proxy=None))"
urllib proxy_bypass 10.1.2.3: False
requests should_bypass_proxies: True

CPython 3.15.0’s urllib returned False for the same call. If a service must reach an internal network directly and more than one runtime is involved, list the addresses or hostnames rather than the range.

Ports. An entry with a port, example.org:8080, exempted nothing on port 80 in any client. That is consistent, and occasionally the reason a “bypassed” host still goes through the proxy.

Node: the flag, and one difference on the wire

Node is the only major runtime where setting the variables does nothing by default. Starting it with NODE_USE_ENV_PROXY=1, or the --use-env-proxy flag, makes global fetch honour them on 24.0.0 and later. Our proxy log showed one difference from every other client. For a plain http:// URL, curl, wget, Python, Go and axios all sent GET http://example.org/ to the proxy. Node 24.2.0’s fetch sent CONNECT example.org:80 and tunnelled instead. A proxy that only allows CONNECT to TLS ports, which is what Squid’s documented default rule http_access deny CONNECT !SSL_ports does, will refuse that request. Client-by-client configuration for Node is in the Node.js proxy guide.

Proving which variable actually applied

Do not infer it. Ask the destination which address it saw, then repeat with the environment cleared:

# With whatever the environment says
curl -s https://api.ipify.org

# With every proxy variable removed, as a control
env -u http_proxy -u https_proxy -u HTTP_PROXY -u HTTPS_PROXY \
    -u all_proxy -u ALL_PROXY -u no_proxy -u NO_PROXY \
    curl -s https://api.ipify.org

If the two agree, no proxy was applied, whatever the variables say. curl’s verbose output also states it. A proxied request prints Uses proxy env variable https_proxy and connects to the gateway. With only uppercase HTTP_PROXY set, curl 8.7.1 printed Connected to example.org (172.66.157.237) port 80 and nothing about a proxy. On a rotating endpoint, the reported address describes one exit at one moment, not the pool.

Where the variables do not reach

Most reports of “I set the proxy and nothing happened” come from one of these boundaries.

Containers. docker run starts a process with its own environment. Pass the variables explicitly. For builds, Docker treats the proxy variables as predefined build arguments, so they work with --build-arg without an ARG line in the Dockerfile, and Docker leaves them out of docker history by default. Pulling the image is a third case: the daemon makes that request and reads its own configuration.

# Runtime
docker run -e http_proxy -e https_proxy -e no_proxy myimage

# Build time: predefined ARGs, no Dockerfile change needed
docker build --build-arg http_proxy --build-arg https_proxy --build-arg no_proxy .

Service managers and cron. A systemd unit gets the environment systemd gives it, not your login shell’s. Exporting a variable in .bashrc and restarting the service changes nothing; put it in the unit as Environment= or an EnvironmentFile. Cron runs with a deliberately minimal environment for the same reason.

Windows. The lowercase convention comes from Unix. Native Windows HTTP stacks read WinHTTP or WinINET settings, so tools built on them ignore the variables. Tools that bring their own HTTP client, such as curl, Python and Go, still read them. In PowerShell:

$env:http_proxy  = "http://gw.example.net:8000"
$env:https_proxy = "http://gw.example.net:8000"

The pattern behind all three: the variables configure a process, and only processes that inherited them are affected.

Troubleshooting

Symptom Likely cause Fix
curl or wget goes direct for http:// URLs Only uppercase HTTP_PROXY is set Set http_proxy
wget goes direct for https:// URLs Only uppercase HTTPS_PROXY is set Set https_proxy
An internal host goes through the proxy in Go but not Python .example.org does not cover the apex in Go List example.org,.example.org
A 10.0.0.0/8 exemption works in curl but not urllib or httpx No CIDR matching in those clients List the addresses or hostnames
Node traffic leaves from your own address Node does not read the variables by default NODE_USE_ENV_PROXY=1, or a dispatcher
aiohttp ignores the proxy Sessions default to trust_env=False ClientSession(trust_env=True)
Go errors with “refusing to use HTTP_PROXY value in CGI environment” REQUEST_METHOD is set Use http_proxy, or unset REQUEST_METHOD outside CGI
A systemd service ignores the proxy you exported Services do not inherit your shell Environment= in the unit

When environment variables are the wrong tool

They are process-wide and inherited. That suits a one-off shell session and causes trouble elsewhere.

  • Credentials leak. Anything that dumps the environment on error, or a verbose log like the curl output above, prints the password.
  • Everything inherits them. A package manager, a telemetry agent and a health check all start using the proxy. On metered bandwidth that is traffic you pay for and did not mean to send. git, npm and pip each read them differently again.
  • No per-request routing. Work that needs a different session or country per request needs client-level configuration, as in proxies in Python or curl’s -x.

Use the environment for interactive work and for tools with no other option. For anything unattended, configure the client directly, so the setting lives in the code that depends on it.

How this was tested

All results come from runs on 21 October 2026 on macOS. A local forward proxy on 127.0.0.1 logged one line per request and either answered plain-HTTP requests itself or tunnelled CONNECT to the real destination. Each client ran in a clean environment containing only PATH, HOME and the variables under test, so nothing leaked in from the shell. A request counted as proxied only when the log recorded it. For the no_proxy rows, the hosts were chosen so that a bypass is visible as a direct attempt: api.example.org does not resolve, and 10.1.2.3 times out, so neither can succeed without the proxy. Each cell is a single run, and controls with no variables and with an empty no_proxy confirmed both outcomes are detectable for every client.

Versions: curl 8.7.1, GNU wget 1.25.0, CPython 3.9.6 with requests 2.32.3, httpx 0.27.2 and aiohttp 3.10.5, CPython 3.15.0, Go 1.24.4, Node.js 24.2.0 and 18.13.0, axios 1.7.7 and 1.18.1. GitLab compared curl, wget, Ruby, Python, Go and Java in 2021 and also found no shared standard. Rows do move: curl has added CIDR support since then, in 7.86.0. Re-run the check on your own runtime before depending on any row.

Frequently asked questions

Why does curl ignore HTTP_PROXY but honour http_proxy?
In a CGI environment a request header named Proxy reaches the script as HTTP_PROXY, so honouring it would let any visitor redirect the server's outbound traffic. This was disclosed in 2016 as httpoxy. curl and wget read only the lowercase name, Python drops the uppercase one when REQUEST_METHOD is set, and Go returns an error.
Does no_proxy support wildcards?
Only a single asterisk is close to universal, and it means bypass everything; wget 1.25.0 ignored even that. A pattern like *.example.org worked in Go, Node and axios but was ignored by curl, wget and every Python client tested. Write .example.org instead, plus the apex domain.
Does no_proxy accept CIDR ranges like 10.0.0.0/8?
In curl (since 7.86.0), requests and Go, yes. In Python's urllib, httpx, aiohttp, wget, Node and axios, no: they compare strings and send the request to the proxy. List the addresses when more than one runtime is involved.
Should I set the uppercase or lowercase variables?
Set the lowercase ones; every client that reads the environment honoured them. Adding uppercase HTTPS_PROXY and NO_PROXY is harmless and helps tools that only check that case. Do not rely on uppercase HTTP_PROXY alone.
Why does Node ignore HTTPS_PROXY?
Node's HTTP clients do not read the variables by default. Start Node 24 or later with NODE_USE_ENV_PROXY=1 to make fetch honour them. On 24.2.0 that did not cover http.get, which the documentation lists as gaining support in 24.5.0.
Why does my systemd service ignore the proxy I exported?
A service does not inherit your login shell. Put the setting in the unit as an Environment= line or an EnvironmentFile. Cron behaves the same way.

Sources

  1. curl manual: proxy environment variables
  2. libcurl CURLOPT_NOPROXY: CIDR support since 7.86.0 and the single wildcard
  3. httpoxy: the CGI namespace collision behind the HTTP_PROXY exception
  4. Python urllib.request: getproxies and proxy_bypass
  5. requests 2.32.3 source: should_bypass_proxies and CIDR matching
  6. Go httpproxy: NO_PROXY matching and the CGI rule
  7. Node.js CLI: NODE_USE_ENV_PROXY
  8. Node.js http: built-in proxy support and NO_PROXY format
  9. GNU Wget manual: proxies
  10. Dockerfile reference: predefined proxy ARGs
  11. Squid FAQ: the default CONNECT !SSL_ports rule
  12. GitLab (2021): Can we standardize NO_PROXY?

Read this page as Markdown · Quote it freely under CC BY 4.0 with a link back.