Skip to content
Fixedmark

Platforms · 10 min read

Updated

NO_PROXY Rules in curl, Node, Python, and Go Compared

HTTPS_PROXY and NO_PROXY have no standard, so every client parses them its own way. curl, Python, Node.js, and Go disagree on which case wins, whether `example.com` covers subdomains, and whether CIDR ranges, ports, and `*.` wildcards work. When only some calls need a proxy, pass the proxy to those clients in code and keep it out of the global environment.

On this page

There is no NO_PROXY standard

The proxy variables date back to libwww in the 1990s. No RFC defines them. Each HTTP library reads them as its authors saw fit, and the results drift apart in small ways. GitLab hit this in production and wrote it up in We need to talk: Can we standardize NO_PROXY?. Their summary is blunt. HTTP is a well-defined standard, but no standard exists for how clients handle these variables.

The variables themselves are simple. HTTP_PROXY names the proxy for http:// URLs. HTTPS_PROXY names the proxy for https:// URLs. NO_PROXY lists hosts that skip the proxy. Some clients also read ALL_PROXY. Each one has a lowercase twin, and the twins are where the trouble starts.

This matters most when you want selective proxying. A typical case is an app on a serverless platform whose egress IP changes (see why serverless egress IPs change). One partner API only accepts a fixed IP, so its calls must go through a static IP proxy. Everything else, such as your database, logging, and telemetry, should go direct. With the environment variables, a single NO_PROXY entry decides which side every call lands on. If two libraries in your process read that entry differently, one of them sends traffic the wrong way.

How we tested six clients

GitLab's post first ran in 2021 and some clients have changed since. So we ran our own matrix in November 2026. We started a fake proxy that logs the first line of each connection and answers 403. Then we pointed each client at it through the environment and asked for a set of URLs. If the proxy logged a CONNECT, the client used the proxy. If not, it went direct.

  • curl 8.21.0.
  • Python requests 2.33.1 and 2.34.2, on Python 3.13.
  • Python httpx 0.28.1, the latest release.
  • Go 1.26.4 net/http with the default transport. We checked that the release-branch.go1.27 source has the same proxy code.
  • Node.js 26.5 global fetch and the https module, both with NODE_USE_ENV_PROXY=1.

The method works for any client you want to check. Start a listener, set the variables, and see whether it gets a connection.

Terminal
# Terminal 1: a listener that prints whatever arrives
nc -l 127.0.0.1 18082

# Terminal 2: does curl send this URL to the proxy?
HTTPS_PROXY=http://127.0.0.1:18082 NO_PROXY=example.com \
  curl -s -m 2 -o /dev/null https://api.example.com/
# Nothing printed in terminal 1: curl skipped the proxy.

Which variable wins

Most clients prefer the lowercase variable when both cases are set. Go is the exception in every released version. The table shows what each client did when https_proxy and HTTPS_PROXY pointed at two different proxies, and when only some variables were set.

Proxy variable precedence, tested November 2026 (Node with NODE_USE_ENV_PROXY=1)
ClientReads uppercase HTTP_PROXYWins when both cases are sethttps:// falls back to HTTP_PROXYReads ALL_PROXY
curl 8.21NoLowercaseNoYes
requests 2.34YesLowercaseNoYes
httpx 0.28YesLowercaseNoYes
Go 1.26 and 1.27YesUppercaseNoNo
Node.js fetchYesLowercaseYesNo
Node.js http and httpsYesLowercaseNoNo

Why curl ignores uppercase HTTP_PROXY

In a CGI program, a request header named Proxy arrives as the environment variable HTTP_PROXY. An attacker can set it. This class of bug was disclosed in 2016 as httpoxy. curl's documentation says http_proxy is only accepted in lowercase for this reason. Uppercase HTTPS_PROXY still works in curl. Go takes a different route. Its httpproxy package refuses to use HTTP_PROXY when REQUEST_METHOD is set, which marks a CGI process.

Go is changing its precedence

Go 1.26 and 1.27 read HTTPS_PROXY before https_proxy, and NO_PROXY before no_proxy. In July 2026 the Go team merged a change to golang.org/x/net that prefers lowercase, to match what most other tools do. The tracking issue is golang/go#79656. Go's master branch already vendors the new code. The released 1.27 branch does not. So the same environment can route differently after a Go upgrade, but only if you set both cases to different values.

Node's fetch has a fallback the others lack

With only HTTP_PROXY set, Node's fetch sent an https:// request through it. Every other client went direct. This is documented behaviour of undici's EnvHttpProxyAgent, which says that if only http_proxy is set, it is used for both HTTP and HTTPS requests. If you set HTTP_PROXY for some unrelated tool, Node's fetch starts proxying your HTTPS calls too.

How each client matches NO_PROXY entries

This is where the clients disagree most. Each row sets HTTPS_PROXY and one NO_PROXY value, then requests one URL. Bypass means the request went direct. Proxied means it went through the proxy.

NO_PROXY matching by client, tested November 2026. requests is 2.34.2.
NO_PROXY / URL hostcurlrequestshttpxGoNode fetchNode https
example.com / api.example.comBypassBypassBypassBypassBypassProxied
example.com / notexample.comProxiedProxiedProxiedProxiedProxiedProxied
.example.com / example.comBypassBypassProxiedProxiedBypassBypass
.example.com / api.example.comBypassBypassBypassBypassBypassBypass
*.example.com / api.example.comProxiedProxiedProxiedBypassBypassBypass
10.0.0.0/8 / 10.1.2.3BypassBypassProxiedBypassProxiedProxied
example.com:8443 / api.example.com:8443ProxiedBypassBypassBypassBypassProxied
* / api.example.comBypassBypassBypassBypassBypassBypass
(unset) / localhostProxiedProxiedProxiedBypassProxiedProxied

Only three rows agree across all six clients. A bare * disables the proxy everywhere, .example.com always covers subdomains, and example.com no longer matches notexample.com on current versions. Every other form behaves differently in at least one client.

  • A bare domain covers subdomains in most clients. Node's built-in http and https agent treats example.com as an exact host. Its documentation lists example.com as an exact match and .example.com as the suffix form.
  • A leading dot matches the apex domain in curl, requests, and Node. In Go and httpx, .example.com matches subdomains only. The Go docs state this outright.
  • The *. wildcard is not a wildcard in curl. The libcurl docs say the only wildcard is a single *. requests and httpx do not treat it as one either.
  • CIDR works in curl (since 7.86.0), requests, and Go. httpx and Node ignored 10.0.0.0/8. Node's http module accepts IP ranges in the form 192.168.1.1-192.168.1.100 instead.
  • CIDR only ever matches when the URL itself contains an IP address. None of these clients resolve a host name to check it against a range. GitLab found that only Ruby does.
  • A port in an entry is ignored by curl. curl compares host names only, so example.com:8443 matched nothing.

Surprises that send traffic the wrong way

The matrix shows parsing. These are the behaviours that cause incidents, each one reproduced in our tests.

requests before 2.34 matched too much

With NO_PROXY=example.com, requests 2.33.1 sent https://notexample.com direct. It used a plain string suffix check, so any host ending in those characters matched. The 2.34.0 release notes say requests no longer performs greedy matching on no_proxy domains. Version 2.34.0 shipped in May 2026. Many lock files still pin older versions, so check yours.

One Node process, two matchers

NODE_USE_ENV_PROXY=1 turns on proxy support for both fetch and the http and https modules. They do not share a matcher. With NO_PROXY=example.com, fetch sent api.example.com direct while https.get sent the same URL through the proxy. An SDK built on https and your own fetch calls can therefore split, in the same process, on the same variable. The Node docs mark the feature as active development.

Go never proxies localhost and reads the environment once

Go's http.ProxyFromEnvironment returns no proxy for localhost and loopback addresses, whatever you set. Go also caches the environment. The default transport reads the variables once per process through a sync.Once in net/http's transport.go. Calling os.Setenv after the first request changes nothing. undici behaves differently. Its EnvHttpProxyAgent re-reads no_proxy on demand, but reads the proxy URLs only once, when the agent is created.

curl applies NO_PROXY even to an explicit proxy

Passing --proxy on the command line does not override the environment's NO_PROXY. We ran curl --proxy with NO_PROXY=example.com and https://api.example.com went direct. libcurl uses the no_proxy variable whenever its own CURLOPT_NOPROXY option is unset. Add --noproxy '' to force the proxy.

requests lets the environment override a session

Setting session.proxies is not enough when HTTPS_PROXY is also set. The requests docs warn that environment proxies overwrite session values, and point to issue #2018. In our test, the session's proxy lost to the environment's. Proxies passed on each request, or a session with trust_env = False, kept the right one.

An empty lowercase variable can hide the uppercase one

With no_proxy set to an empty string and NO_PROXY=example.com, httpx and both Node paths proxied api.example.com. curl, requests, and Go skipped the empty value and used the uppercase one. Container images and CI systems sometimes export empty variables, so this one is easy to hit without noticing.

Per-client proxy config is the safer pattern

All of these problems share a cause. A global variable is read by every library in the process, each with its own rules. You cannot test every combination, and a dependency upgrade can change the answer. The fix is to stop asking the environment.

  1. Store the proxy URL in a variable no library reads, such as PARTNER_PROXY_URL or FIXEDMARK_PROXY_URL. Do not set HTTPS_PROXY in the app's environment.
  2. Build one client for the allowlisted API with that proxy passed in code. Reuse it.
  3. Build the default client so it ignores the proxy variables, so a stray HTTPS_PROXY from the platform or a base image cannot pull it through the proxy.
  4. Verify the egress IP from the proxied client and from the direct one before you ship.

Explicit settings beat the environment in these clients, with the two exceptions above. curl still applies NO_PROXY, and requests lets the environment override session.proxies. httpx ignores the proxy variables entirely when you pass proxy=. Go's http.ProxyURL and undici's ProxyAgent never look at the environment.

// npm install undici
import { Agent, fetch, ProxyAgent } from "undici";

// One agent per route, created once and reused.
const viaProxy = new ProxyAgent(process.env.FIXEDMARK_PROXY_URL);
const direct = new Agent(); // ignores HTTPS_PROXY and NO_PROXY

// The allowlisted partner call leaves from the static IP.
const orders = await fetch("https://api.partner.example/v1/orders", {
  dispatcher: viaProxy,
});

// Everything else goes direct, whatever the environment says.
const health = await fetch("https://api.internal.example/health", {
  dispatcher: direct,
});

We ran each snippet against the fake proxy with HTTPS_PROXY and NO_PROXY also set to conflicting values. The proxied clients reached the proxy and the direct clients did not. For the Next.js version of this pattern, with route handlers and server actions, see routing only some fetches through a proxy in Next.js.

If you must use the environment variables

Sometimes you cannot change the code. A CLI tool, a vendored SDK, or a build step may only read the environment. Then write values that every client in the matrix reads the same way.

  • Set the lowercase and uppercase names to the same value. This removes the Go precedence difference and the empty-variable trap.
  • To cover a domain and all its subdomains, list both forms, as in example.com,.example.com. That pair bypassed apex and subdomains in all six clients.
  • Do not use *.example.com. curl, requests, and httpx do not treat it as a wildcard.
  • Do not rely on CIDR ranges or ports. List exact IPs and host names instead.
  • Do not put a broad suffix such as .com or .in in the list. It sends a whole top-level domain direct, including the API you meant to proxy.
  • Set HTTPS_PROXY explicitly. Do not count on a fallback from HTTP_PROXY, since only Node's fetch does that.

Then ask each library what it will do, rather than reading code. requests and Go expose the decision function directly.

NO_PROXY=example.com,.example.com HTTPS_PROXY=http://proxy.internal:3128 \
  python -c 'import requests.utils as u; print(u.get_environ_proxies("https://api.example.com/"))'
# {} means requests will go direct for this URL.

For Node and curl, use the listener method from the testing section. Check the egress IP as the last step either way. Our egress IP check shows how, and why requests skip the proxy covers the common causes.

Doing this with Fixedmark

Fixedmark gives an app a static outbound IP pair through one proxy URL. It is in early access. The docs name that URL FIXEDMARK_PROXY_URL on purpose. No library reads that variable, so nothing gets proxied until you pass it to a client. The language guides for Node.js, Python, and Go show the per-client setup for each library, including axios and SDKs that take an agent.

Selective proxying also matters for cost. Each call through the proxy counts against your plan's bandwidth, so a global HTTPS_PROXY that catches telemetry or database APIs adds usage you did not intend. See pricing for the planned plans.

Two features help catch mistakes. Destination allowlists, on plans that include them, restrict a proxy credential to the hosts and ports you list, such as the one partner API. A call that leaks into the proxy fails instead of quietly leaving from your static IP. Connection logs show the destination, SNI, and egress IP of each connection, so you can see exactly which hosts went through.

Sources

Checked November 2026. Confirm current details on the vendor's site before you decide. Prices and limits change.

Blog

Frequently asked questions

Which wins, HTTPS_PROXY or https_proxy?

Lowercase wins in curl, Python requests, httpx, and Node.js. Released Go versions (1.26 and 1.27) prefer uppercase. Go's master branch has switched to lowercase. Set both names to the same value to avoid the difference.

Does NO_PROXY support wildcards like *.example.com?

Not portably. Go and Node.js treat *.example.com as a subdomain wildcard. curl, Python requests, and httpx do not. Use the pair example.com,.example.com instead, which worked in all six clients we tested.

Does NO_PROXY support CIDR ranges?

curl 7.86.0 and later, Python requests, and Go support CIDR. httpx and Node.js do not. In every client a range only matches when the URL contains an IP address, because no client resolves the host name first.

Why does Go ignore my proxy for localhost?

http.ProxyFromEnvironment never proxies localhost or loopback addresses. Use a transport with http.ProxyURL when you need to send local traffic through a proxy, for example in a test.

Does curl --proxy ignore NO_PROXY?

No. curl still applies the no_proxy environment variable to a proxy given with --proxy. Add --noproxy '' to force the proxy for every host.

Make it fixed.

Fixedmark is in early access. Join the list to get dedicated static IPs when your region opens.