---
title: "Internal calls failing through a proxy from environment variables | Proofline"
description: "When an internal call fails with a 403, 407 or 502 that the dependency never logged, check whether the client sent it to a proxy from its environment."
url: https://proofline.sh/learn/proxy-environment-variables-internal-calls/
---

[Learning center](/learn/)

# Internal calls failing through a proxy from environment variables

When an internal call fails with a 403, 407 or 502 that the dependency never logged, check whether the client sent it to a proxy from its environment. Read the process's environment, then repeat the call with curl -v under the same variables: a CONNECT request to the proxy means the error came from the proxy. Libraries read these variables differently, so two clients in the same container can take different paths.

Network outages The Proofline team November 23, 2026 6 min read

## The symptom and its nearby causes

A service calls an internal dependency by name, such as `https://orders.example.internal`, and gets an HTTP error or a failed tunnel, while the dependency's access log has no request at that time. Three causes produce it:

-   **The proxy carries an internal call.** A proxy variable is set for outbound internet traffic, and the internal host is missing from `NO_PROXY`. The proxy refuses the destination, cannot reach it, or asks for credentials. RFC 9110 defines 407 as the proxy's request for authentication and 502 as a gateway or proxy that received an invalid response from the server behind it. [RFC 9110: 407](https://www.rfc-editor.org/rfc/rfc9110.html#section-15.5.8) · [RFC 9110: 502](https://www.rfc-editor.org/rfc/rfc9110.html#section-15.6.3)
-   **The NO\_PROXY entry has a form this library does not match.** Each library parses the list itself, so an entry that bypasses the proxy for one client sends another client through it.
-   **One client ignores the variables.** A process that goes direct while its neighbours use the proxy fails when the network only allows egress through the proxy, and the failure looks like a connect timeout instead of a proxy error. [Refused or timed out](/learn/connection-refused-vs-timeout/)

## Why they look alike

For an HTTPS destination the client first opens a TCP connection to the proxy and sends `CONNECT host:port`. The proxy then opens its own connection to the destination and, if that succeeds, forwards bytes in both directions. Any failure before the tunnel exists, from DNS on the proxy to an access rule, comes back as the proxy's response to CONNECT, so the client library reports it as a failed request to the dependency's URL. [RFC 9110: CONNECT](https://www.rfc-editor.org/rfc/rfc9110.html#section-9.3.6)

The variables usually come from a base image, a platform default or a shared configuration file, and they apply to every client in the process that honours them. A release that adds a new internal hostname, or a library that starts honouring the variables after an upgrade, changes the path without any proxy setting in the diff.

## How the common clients read the variables

| Client | Variables it reads | Notes |
| --- | --- | --- |
| curl | `http_proxy`, `HTTPS_PROXY`, `NO_PROXY`, `ALL_PROXY` | Either case, lowercase wins; `http_proxy` lowercase only |
| Go `net/http` | `HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY` | Either case; the default transport uses them |
| Python urllib | `<scheme>_proxy`, `no_proxy` | Any case, lowercase wins |
| Python Requests | `http_proxy`, `https_proxy`, `no_proxy`, `all_proxy` | Either case, unless `trust_env` is off |
| Node.js `http`, `fetch` | `HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY` | Only with `NODE_USE_ENV_PROXY=1` or `--use-env-proxy` |

curl ignores an uppercase `HTTP_PROXY`, so `curl http://...` can go direct where a Go service with the same environment uses the proxy. Its `NO_PROXY` matches a host or any domain that contains it, and `*` disables the proxy. [curl environment variables](https://curl.se/docs/manpage.html#ENVIRONMENT)

Go's `DefaultTransport` uses `ProxyFromEnvironment`, which never proxies `localhost`. The `httpproxy` package documents the `NO_PROXY` forms: IP prefixes, CIDR ranges, domain names matching the name and its subdomains, a leading dot for subdomains only, optional ports, and `*`. [net/http ProxyFromEnvironment](https://pkg.go.dev/net/http#ProxyFromEnvironment) · [httpproxy Config](https://pkg.go.dev/golang.org/x/net/http/httpproxy#Config)

Python's `urllib.request.getproxies()` scans the environment for `<scheme>_proxy` in any case and prefers lowercase when the two disagree; `no_proxy` is a list of hostname suffixes with optional ports. It ignores `HTTP_PROXY` when `REQUEST_METHOD` is set. Requests reads the same variables when the session's `trust_env` is true, and the environment overrides values set on `session.proxies`. [urllib getproxies](https://docs.python.org/3/library/urllib.request.html#urllib.request.getproxies) · [Requests proxies](https://requests.readthedocs.io/en/latest/user/advanced/#proxies) · [Session.trust\_env](https://requests.readthedocs.io/en/latest/api/#requests.Session.trust_env)

Node.js parses the variables at startup only when `NODE_USE_ENV_PROXY=1` or `--use-env-proxy` is set, added in v24 and v22.21 and marked active development. Its `NO_PROXY` accepts exact hosts, `.example.com` suffixes, `*.example.com` wildcards, IP addresses and IP ranges. Third-party HTTP libraries may read the variables on their own, so check the one the service uses. [Node.js built-in proxy support](https://nodejs.org/api/http.html#built-in-proxy-support) · [NODE\_USE\_ENV\_PROXY](https://nodejs.org/api/cli.html#node_use_env_proxy1)

## Read the environment and repeat the call

Read the environment the running process started with. `/proc/PID/environ` holds the initial environment, separated by null bytes; changes the process made afterwards do not appear. In Kubernetes, `kubectl exec` runs a command in the container. [proc\_pid\_environ(5)](https://man7.org/linux/man-pages/man5/proc_pid_environ.5.html) · [Environment variables in a container](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/)

```
tr '\0' '\n' < /proc/PID/environ | grep -i -E '^(https?|all|no)_proxy='
kubectl exec POD -c CONTAINER -- printenv | grep -i proxy
```

Then repeat the call from the same container with the same variables, once as is and once with the proxy disabled. A GET to a health or read-only endpoint keeps the test free of side effects.

```
curl -v -o /dev/null https://orders.example.internal/healthz
curl -v -o /dev/null --noproxy '*' https://orders.example.internal/healthz
```

With a proxy in use, the verbose output shows the connection going to the proxy's address and a `CONNECT orders.example.internal:443` request, followed by the proxy's status line. A status other than 2xx there is the proxy's answer. The second command goes direct: if it succeeds, the dependency is reachable and the proxy path is the fault. `--noproxy` overrides `no_proxy` and `NO_PROXY` for that command only. [curl --noproxy](https://curl.se/docs/manpage.html#--noproxy)

Because curl reads `http_proxy` only in lowercase, a curl test of a plain `http://` URL does not reproduce a client that honours `HTTP_PROXY`. Pass the proxy explicitly with `-x` in that case.

## What each result means

| Result | Points to |
| --- | --- |
| CONNECT answered with 403 or 407 | Proxy policy or credentials: add the host to `NO_PROXY` or ask the proxy owner |
| CONNECT answered with 502 or 503 | The proxy could not reach the host; it may not resolve internal names |
| Direct call works, proxied call fails | The internal host belongs in `NO_PROXY` in the form this library reads |
| No proxy variables, connect timeout | Not this cause; check the network path |
| curl uses the proxy, the service does not | The library ignores the variables; check whether egress requires the proxy |

## An illustrative fixture: two proxy failures

This fixture is illustrative. The `checkout` service image sets `HTTPS_PROXY=http://egress-proxy.example.internal:3128` so that it can reach a payment provider at `api.payments.example.com`, and `NO_PROXY=localhost,.cluster.local`.

In the first incident, a release adds a call from the Go `checkout` binary to `https://orders.example.internal`. Every call fails with a 403 while the orders access log shows nothing. `curl -v` from the container shows `CONNECT orders.example.internal:443` to 10.0.4.20 port 3128 and a 403 from the proxy, whose allowlist covers only external hosts. With `--noproxy '*'` the same request returns 200. Adding `.example.internal` to `NO_PROXY` fixes the path; orders needs nothing.

In the second incident, a Node.js sidecar in the same task calls the payment provider and times out, while `checkout` reaches it. The sidecar runs without `NODE_USE_ENV_PROXY`, so it ignores `HTTPS_PROXY` and connects straight to 203.0.113.40, which the subnet's egress rules drop. The provider is healthy and the proxy is never asked.

## Limits

This covers proxies the client chooses from its own environment. A proxy inserted by the network path, a proxy auto-configuration file, or a proxy set in code does not appear in the environment. A test from a shell can differ from the service when the shell has its own environment or the library has a programmatic override. Some proxies also answer for the destination after the tunnel is up, so a TLS error can come from proxy interception; compare the certificate issuer on the direct and proxied paths. [Hostname mismatch](/learn/tls-hostname-mismatch/) · [The full set of dependency failures](/learn/runtime-dependency-failures/)

## Questions

### Why does curl work when my service fails through the proxy?

curl reads `http_proxy` only in lowercase and has its own `NO_PROXY` matching, so it may take a different path from your service's library. Run curl with `-v` and check whether it connected to the proxy; pass the proxy with `-x` to match the service.

### Does Node.js use HTTPS\_PROXY by default?

No. The built-in `http`, `https` and `fetch` clients use the variables only when `NODE_USE_ENV_PROXY=1` or `--use-env-proxy` is set, or when code enables it. A third-party library may read them itself.

### Can NO\_PROXY hold an IP range?

It depends on the client. Go's `httpproxy` accepts CIDR notation and Node.js accepts address ranges, while Python's urllib matches hostname suffixes. Use the hostname the client actually requests when you are not sure.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Connection refused or timed out: what each error tells you](/learn/connection-refused-vs-timeout/)
    
    Network outages The Proofline team November 23, 2026 6 min read
    
-   ### [TLS hostname mismatch calling a dependency: which name is wrong?](/learn/tls-hostname-mismatch/)
    
    Network outages The Proofline team November 23, 2026 5 min read
