---
title: "NO_PROXY Rules in curl, Node, Python, and Go Compared"
description: "How curl, Node.js, Python requests, httpx, and Go read HTTPS_PROXY and NO_PROXY, where they disagree, and why per-client proxy config is the safer pattern."
canonical: https://fixedmark.com/blog/selective-proxying-no-proxy-and-per-client-agents
updated: 2026-11-10
source: Fixedmark (https://fixedmark.com), BitMask LLP
---

Platforms · 10 min read

# 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.

## 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?](https://about.gitlab.com/blog/we-need-to-talk-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](https://fixedmark.com/blog/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**

```bash
# 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)_

| Client                 | Reads uppercase HTTP_PROXY | Wins when both cases are set | https\:// falls back to HTTP_PROXY | Reads ALL_PROXY |
| ---------------------- | -------------------------- | ---------------------------- | ---------------------------------- | --------------- |
| curl 8.21              | No                         | Lowercase                    | No                                 | Yes             |
| requests 2.34          | Yes                        | Lowercase                    | No                                 | Yes             |
| httpx 0.28             | Yes                        | Lowercase                    | No                                 | Yes             |
| Go 1.26 and 1.27       | Yes                        | Uppercase                    | No                                 | No              |
| Node.js fetch          | Yes                        | Lowercase                    | Yes                                | No              |
| Node.js http and https | Yes                        | Lowercase                    | No                                 | No              |

### 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](https://httpoxy.org/). curl's documentation says `http_proxy` is [only accepted in lowercase](https://everything.curl.dev/usingcurl/proxies/env.html) for this reason. Uppercase `HTTPS_PROXY` still works in curl. Go takes a different route. Its [httpproxy package](https://pkg.go.dev/golang.org/x/net/http/httpproxy) 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](https://github.com/golang/net/commit/a02ddfa7eacb4cf63a5bea6b23761244a6df69f6) that prefers lowercase, to match what most other tools do. The tracking issue is [golang/go#79656](https://github.com/golang/go/issues/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](https://github.com/nodejs/undici/blob/main/docs/docs/api/EnvHttpProxyAgent.md), 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 host                         | curl    | requests | httpx   | Go      | Node fetch | Node https |
| ------------------------------------------- | ------- | -------- | ------- | ------- | ---------- | ---------- |
| `example.com` / `api.example.com`           | Bypass  | Bypass   | Bypass  | Bypass  | Bypass     | Proxied    |
| `example.com` / `notexample.com`            | Proxied | Proxied  | Proxied | Proxied | Proxied    | Proxied    |
| `.example.com` / `example.com`              | Bypass  | Bypass   | Proxied | Proxied | Bypass     | Bypass     |
| `.example.com` / `api.example.com`          | Bypass  | Bypass   | Bypass  | Bypass  | Bypass     | Bypass     |
| `*.example.com` / `api.example.com`         | Proxied | Proxied  | Proxied | Bypass  | Bypass     | Bypass     |
| `10.0.0.0/8` / `10.1.2.3`                   | Bypass  | Bypass   | Proxied | Bypass  | Proxied    | Proxied    |
| `example.com:8443` / `api.example.com:8443` | Proxied | Bypass   | Bypass  | Bypass  | Bypass     | Proxied    |
| `*` / `api.example.com`                     | Bypass  | Bypass   | Bypass  | Bypass  | Bypass     | Bypass     |
| (unset) / `localhost`                       | Proxied | Proxied  | Proxied | Bypass  | Proxied    | Proxied    |

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](https://nodejs.org/api/http.html#built-in-proxy-support) 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](https://curl.se/libcurl/c/CURLOPT_NOPROXY.html) 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](https://github.com/psf/requests/blob/main/HISTORY.md) 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](https://requests.readthedocs.io/en/latest/user/advanced/#proxies) 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.

**Node.js**

```javascript
// 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,
});
```

**Python requests**

```python
import os
import requests

partner = requests.Session()
# Ignore HTTPS_PROXY and NO_PROXY so session.proxies is never overridden.
# This also turns off REQUESTS_CA_BUNDLE and .netrc for this session.
partner.trust_env = False
partner.proxies = {"https": os.environ["FIXEDMARK_PROXY_URL"]}

res = partner.get("https://api.partner.example/v1/orders", timeout=15)
```

**Python httpx**

```python
# pip install "httpx>=0.28"
import os
import httpx

# proxy= replaces every proxy variable for this client, NO_PROXY included.
partner = httpx.Client(proxy=os.environ["FIXEDMARK_PROXY_URL"], timeout=15)

# trust_env=False makes the default client ignore the proxy variables.
direct = httpx.Client(trust_env=False, timeout=15)

res = partner.get("https://api.partner.example/v1/orders")
```

**Go**

```go
package main

import (
	"log"
	"net/http"
	"net/url"
	"os"
	"time"
)

func newClient(proxy func(*http.Request) (*url.URL, error)) *http.Client {
	t := http.DefaultTransport.(*http.Transport).Clone()
	t.Proxy = proxy // nil means always direct
	return &http.Client{Transport: t, Timeout: 15 * time.Second}
}

func main() {
	proxyURL, err := url.Parse(os.Getenv("FIXEDMARK_PROXY_URL"))
	if err != nil {
		log.Fatal(err)
	}
	partner := newClient(http.ProxyURL(proxyURL))
	direct := newClient(nil)

	res, err := partner.Get("https://api.partner.example/v1/orders")
	if err != nil {
		log.Fatal(err)
	}
	defer res.Body.Close()
	_ = direct
}
```

**curl**

```bash
# Force the proxy, even if NO_PROXY in the environment matches.
curl --noproxy '' --proxy "$FIXEDMARK_PROXY_URL" \
  https://api.partner.example/v1/orders

# Force a direct connection, even if HTTPS_PROXY is set.
curl --noproxy '*' https://api.internal.example/health
```

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](https://fixedmark.com/blog/nextjs-route-only-some-fetches-through-a-proxy).

## 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.

**Python**

```bash
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.
```

**Go**

```go
// go run . https://api.example.com/
package main

import (
	"fmt"
	"net/http"
	"os"
)

func main() {
	req, err := http.NewRequest("GET", os.Args[1], nil)
	if err != nil {
		panic(err)
	}
	// The same function http.DefaultTransport uses.
	proxy, err := http.ProxyFromEnvironment(req)
	fmt.Println(proxy, err) // <nil> <nil> means direct
}
```

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](https://fixedmark.com/docs/verify-egress-ip) shows how, and [why requests skip the proxy](https://fixedmark.com/docs/troubleshooting#bypass) 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](https://fixedmark.com/docs/node), [Python](https://fixedmark.com/docs/python), and [Go](https://fixedmark.com/docs/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](https://fixedmark.com/pricing) for the planned plans.

Two features help catch mistakes. [Destination allowlists](https://fixedmark.com/docs/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](https://fixedmark.com/docs/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.

- [GitLab: We need to talk: Can we standardize NO_PROXY?](https://about.gitlab.com/blog/we-need-to-talk-no-proxy/)
- [Everything curl: Proxy environment variables](https://everything.curl.dev/usingcurl/proxies/env.html)
- [libcurl: CURLOPT_NOPROXY](https://curl.se/libcurl/c/CURLOPT_NOPROXY.html)
- [Requests: Advanced usage, Proxies](https://requests.readthedocs.io/en/latest/user/advanced/#proxies)
- [Requests: Release history (2.34.0 no_proxy fix)](https://github.com/psf/requests/blob/main/HISTORY.md)
- [HTTPX: Environment variables](https://www.python-httpx.org/environment_variables/)
- [Go: golang.org/x/net/http/httpproxy](https://pkg.go.dev/golang.org/x/net/http/httpproxy)
- [Go: http/httpproxy, prioritize lowercase proxy variables](https://github.com/golang/net/commit/a02ddfa7eacb4cf63a5bea6b23761244a6df69f6)
- [Node.js: Built-in proxy support](https://nodejs.org/api/http.html#built-in-proxy-support)
- [undici: EnvHttpProxyAgent](https://github.com/nodejs/undici/blob/main/docs/docs/api/EnvHttpProxyAgent.md)
- [httpoxy: CGI HTTP_PROXY vulnerability](https://httpoxy.org/)

Keep reading

## Related guides

- [Use case Partner API allowlisting Give Salesforce, SOAP vendors, and payment gateways one dedicated IP pair to allowlist, wherever your code runs.](https://fixedmark.com/use-cases/partner-api-allowlisting)
- [Integration AWS Lambda A fixed IP for Lambda without VPC, subnets, and two NAT Gateways.](https://fixedmark.com/integrations/aws-lambda)
- [Integration Vercel Fixed egress IPs for Vercel Functions without the $100 per project add-on.](https://fixedmark.com/integrations/vercel)
- [Guide Fixedmark docs Set up the proxy URL per client in Node.js, Python, Go, Java, PHP, and Ruby.](https://fixedmark.com/docs)
- [Tool What's my IP Check which public IP a request leaves from.](https://fixedmark.com/tools/whats-my-ip)

## 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.
