---
title: "Proxy error: what each message means and how to fix it"
url: https://proxy.wiki/guides/proxy-error/
type: Guide
author: "proxy.wiki editorial"
published: 2026-10-21
updated: 2026-10-21
site: proxy.wiki
topics: ["Proxy fundamentals"]
license: CC BY 4.0; quote freely with attribution to https://proxy.wiki/
---

# Proxy error: what each message means and how to fix it

> Exact proxy error messages from curl, Python, Node, Chrome, Squid and Apache, reproduced on a test rig, with the cause and fix for each.

## Key takeaways

- A proxy error names one of two hops: your client to the proxy, or the proxy to the next server. Find which before changing code.
- curl -w '%{http_connect}' prints the proxy's answer to CONNECT; Chrome and Node 24 fetch fold several proxy statuses into one generic error.
- A password containing @ or # must be percent-encoded. Raw, curl reports "Could not resolve proxy" instead of a 407.
- Squid and Apache sent different status codes for the same upstream failure, so read the error page, header or log line, not just the number.
- Cloudflare 10xx pages enforce the site owner's own rules; contact the owner with the Ray ID rather than retrying.

A proxy error means the request died at a machine in the middle, not at the website you asked for. Two hops can break: the one from your client to the proxy, and the one from the proxy to the next server. Every message on this page points at one of those two hops, and once you know which, the fix is usually a single line.

If you saw a web page like this one, you met a [reverse proxy](/glossary/reverse-proxy/) sitting in front of a website:

```
Proxy Error

The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request

Reason: Error reading from remote server
```

That is Apache httpd’s built-in error page. We produced it, with the status line `HTTP/1.1 502 Proxy Error`, by putting Apache 2.4.67 in front of a backend that hangs up without answering. A visitor cannot fix it from their side. The application behind the site has crashed, stalled or gone away, and the [reverse proxy section](#reverse-proxy-errors) lists what the owner should look at.

If you write code that sends traffic through a [forward proxy](/glossary/forward-proxy/), your message reads more like one of these:

```
curl: (7) CONNECT tunnel failed, response 407
curl: (5) Could not resolve proxy: gw.invalid
requests.exceptions.ProxyError: ... (Caused by ProxyError('Unable to connect to proxy', OSError('Tunnel connection failed: 407 Proxy Authentication Required')))
httpx.ProxyError: 503 Service Unavailable
net::ERR_PROXY_CONNECTION_FAILED
net::ERR_TUNNEL_CONNECTION_FAILED
```

## Find your exact message

Each row is one failure we caused on purpose against servers running on our own machine. The columns show what five clients printed for it. Find your string, then jump to the cause. A dash means we did not run that combination.

| Failure | curl 8.23.0 | Python requests 2.34.2 | httpx 0.28.1 | Node 24.2.0 fetch | Chrome 155 |
| --- | --- | --- | --- | --- | --- |
| [Nothing listening on the proxy port](#cannot-reach) | (7) Failed to connect to … over proxy | ProxyError('Unable to connect to proxy', NewConnectionError(… [Errno 61] Connection refused | ConnectError: [Errno 61] Connection refused | fetch failed, cause ECONNREFUSED | ERR_PROXY_CONNECTION_FAILED |
| [Proxy hostname does not resolve](#cannot-reach) | (5) Could not resolve proxy: gw.invalid | NameResolutionError(… Failed to resolve 'gw.invalid' | ConnectError: [Errno 8] nodename nor servname provided, or not known | fetch failed, cause ENOTFOUND | ERR_PROXY_CONNECTION_FAILED |
| [Missing or wrong proxy password](#auth) | (7) CONNECT tunnel failed, response 407 | Tunnel connection failed: 407 Proxy Authentication Required | ProxyError: 407 Proxy Authentication Required | fetch failed, cause Request was cancelled. | ERR_INVALID_AUTH_CREDENTIALS |
| [Password contains @ or #, not encoded](#auth) | (5) Could not resolve proxy: ss | Failed to resolve 'ss' | ConnectError: [Errno 8] … | Process crashes: InvalidArgumentError: invalid url | — |
| [https:// used for a plain HTTP proxy](#protocol) | (35) TLS connect error: … wrong version number | Your proxy appears to only use HTTP and not HTTPS | ConnectError: [SSL: WRONG_VERSION_NUMBER] | cause ERR_SSL_WRONG_VERSION_NUMBER | ERR_PROXY_CONNECTION_FAILED |
| [Address is a web server, not a proxy](#protocol) | (7) CONNECT tunnel failed, response 501 | Tunnel connection failed: 501 Unsupported method ('CONNECT') | ProxyError: 501 Unsupported method ('CONNECT') | cause Request was cancelled. | ERR_TUNNEL_CONNECTION_FAILED |
| [Proxy forbids the destination port](#policy) | (7) CONNECT tunnel failed, response 403 | Tunnel connection failed: 403 Forbidden | ProxyError: 403 Forbidden | cause Request was cancelled. | ERR_TUNNEL_CONNECTION_FAILED |
| [Proxy cannot reach the destination](#upstream) | (7) CONNECT tunnel failed, response 503 | Tunnel connection failed: 503 Service Unavailable | ProxyError: 503 Service Unavailable | cause Request was cancelled. | ERR_TUNNEL_CONNECTION_FAILED |
| [Proxy closes the connection without a reply](#hangup) | (56) Proxy CONNECT aborted | RemoteDisconnected('Remote end closed connection without response') | RemoteProtocolError: Server disconnected without sending a response. | No error until our own timeout fired | ERR_EMPTY_RESPONSE |
| [Proxy intercepts TLS with its own CA](#tls) | (60) … self-signed certificate in certificate chain (19) | SSLError(… CERTIFICATE_VERIFY_FAILED | ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] | cause SELF_SIGNED_CERT_IN_CHAIN | ERR_CERT_AUTHORITY_INVALID |

Two things stand out. Chrome folds a 403, a 501 and a 503 from the proxy into the same `ERR_TUNNEL_CONNECTION_FAILED`, and Node’s built-in fetch reported all three, plus the 407, as `Request was cancelled.` Neither tells you the status the proxy actually sent. curl and both Python libraries do. When a browser or a Node service fails through a proxy, rerun the same request with curl before changing anything else.

## How these messages were captured

Every string on this page was produced on 21 October 2026 on macOS (Darwin 25.6.0), each case run once, against processes we started ourselves on 127.0.0.1 and nothing else:

- Squid 6.13 with three ports: one requiring Basic [proxy authentication](/glossary/proxy-authentication/), one open, and one doing TLS interception with a lab CA (`ssl_bump`).

- Apache httpd 2.4.67 as a reverse proxy in front of the misbehaving upstreams below.

- A Python origin serving HTTP and HTTPS, signed by a separate “Lab Origin CA”.

- Two hostile upstreams: one that accepts and immediately closes, one that accepts and never answers.

Clients: curl 8.23.0 (Homebrew, OpenSSL 4.0.3) plus the curl 8.7.1 that ships with macOS, Python 3.12.13 with requests 2.34.2, urllib3 2.8.0 and httpx 0.28.1, Node v24.2.0 with `NODE_USE_ENV_PROXY=1`, and Chrome 155.0.8059.85 headless, driven through the DevTools protocol so we could read the exact `net::` error. Hostnames ending in `.invalid` are reserved for exactly this purpose by [RFC 6761 section 6.4](https://www.rfc-editor.org/rfc/rfc6761.html#section-6.4), which makes them a safe way to force a DNS failure.

Error numbers inside messages depend on the operating system. macOS prints `(61) Connection refused`; a Linux build prints `(111)` for the same refusal, because that is the value of `ECONNREFUSED` in the [Linux errno header](https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/errno.h). Search for the words, not the number.

## Find the failing hop with one command

curl can report the proxy’s answer to CONNECT separately from the target’s answer. That single split settles most arguments about whose fault it is. Save this as `proxycheck.sh`:

```
#!/usr/bin/env bash
# proxycheck.sh PROXY_URL [TARGET_URL] [extra curl args]
proxy=$1; target=${2:-https://example.com/}
curl -s -o /dev/null --max-time 15 -x "$proxy" "${@:3}" \
  -w 'connect_to_proxy=%{time_connect}s  proxy_CONNECT=%{http_connect}  target_status=%{http_code}  curl_exit=%{exitcode}  msg="%{errormsg}"\n' \
  "$target"
```

Output from our rig, one line per failure:

```
$ ./proxycheck.sh http://127.0.0.1:46999 https://localhost:46443/
connect_to_proxy=0.000000s  proxy_CONNECT=000  target_status=000  curl_exit=7  msg="Failed to connect to localhost:46443 over proxy 127.0.0.1 after 0 ms: Could not connect to server"

$ ./proxycheck.sh http://127.0.0.1:46128 https://localhost:46443/
connect_to_proxy=0.000183s  proxy_CONNECT=407  target_status=000  curl_exit=7  msg="CONNECT tunnel failed, response 407"

$ ./proxycheck.sh http://127.0.0.1:46130 https://localhost:443/
connect_to_proxy=0.000153s  proxy_CONNECT=503  target_status=000  curl_exit=7  msg="CONNECT tunnel failed, response 503"

$ ./proxycheck.sh http://127.0.0.1:46132 https://localhost:46443/
connect_to_proxy=0.000154s  proxy_CONNECT=200  target_status=000  curl_exit=60  msg="SSL certificate OpenSSL verify result: self-signed certificate in certificate chain (19)"

$ ./proxycheck.sh http://labuser:correct-horse@127.0.0.1:46128 https://localhost:46443/ --cacert certs/origin-ca.pem
connect_to_proxy=0.000154s  proxy_CONNECT=200  target_status=200  curl_exit=0  msg=""
```

Read it left to right. `proxy_CONNECT=000` means you never got an answer from the proxy. Any other value there is the proxy talking. A `200` in that field with a failure afterwards moves the problem past the proxy, to TLS or to the target. If the target itself answers 403 or 429, that is a different family of problem, covered in [403 vs 407 vs 429](/guides/403-vs-407-vs-429/).

Do not script against curl’s exit code for tunnel failures. On the same machine, against the same Squid, curl 8.7.1 exited `56` with `curl: (56) CONNECT tunnel failed, response 407` while curl 8.23.0 exited `7` with the same text. Match on `%{http_connect}` instead.

## Cause 1: the proxy rejected your credentials (407)

The proxy answered, and it wants a username and password it did not get. The verbose exchange shows exactly where:

```
$ curl -sv -x http://labuser:wrong@127.0.0.1:46128 https://localhost:46443/
* Proxy auth using Basic with user 'labuser'
* Establishing HTTP proxy tunnel to localhost:46443
> CONNECT localhost:46443 HTTP/1.1
> Host: localhost:46443
> Proxy-Authorization: Basic <redacted>
< HTTP/1.1 407 Proxy Authentication Required
< Server: squid/6.13
< X-Squid-Error: ERR_CACHE_ACCESS_DENIED 0
< Proxy-Authenticate: Basic realm="proxy-lab"
* Basic authentication problem, ignoring.
curl: (7) CONNECT tunnel failed, response 407
```

407 and the `Proxy-Authenticate` header are defined in [RFC 9110 section 15.5.8](https://www.rfc-editor.org/rfc/rfc9110.html#section-15.5.8). The request never left the proxy, so nothing about the target site is involved. Check, in this order: the password itself, the port (many gateways use the port to select a product), any parameters packed into the username, and whether the account authenticates by [IP allowlist](/glossary/ip-whitelisting/) instead of a password.

The sneakiest version is a password containing `@`, `#`, `:` or `/`. Our second lab user has the password `p@ss#word`. Pasted raw into a proxy URL, every client misread it, and the error message does not mention credentials at all:

```
$ curl -sS -x 'http://labuser2:p@ss#word@127.0.0.1:46128' https://localhost:46443/
curl: (5) Could not resolve proxy: ss
```

The first `@` ends the user information, as [RFC 3986 section 3.2.1](https://www.rfc-editor.org/rfc/rfc3986.html#section-3.2.1) specifies, so curl took `ss` as the proxy host. requests failed the same way (`Failed to resolve 'ss'`), and Node 24.2.0 refused to start at all, throwing `InvalidArgumentError: invalid url` from `EnvHttpProxyAgent` before the script’s first line ran. Percent-encode the password, or keep it out of the URL:

```
# encoded in the URL: @ is %40, # is %23
curl -x 'http://labuser2:p%40ss%23word@127.0.0.1:46128' https://localhost:46443/

# or passed separately, so no encoding is needed
curl -x http://127.0.0.1:46128 --proxy-user 'labuser2:p@ss#word' https://localhost:46443/

# Python: encode once, never by hand
python3 -c "from urllib.parse import quote; print(quote('p@ss#word', safe=''))"
p%40ss%23word
```

Both forms returned `hello from origin` through the authenticating port. Headless Chrome with no credential handler reported the 407 as `net::ERR_INVALID_AUTH_CREDENTIALS`. Library-by-library setup is in the [curl guide](/guides/how-to-use-a-proxy-with-curl/) and the [Python guide](/guides/proxies-in-python-requests-httpx/).

## Cause 2: your client cannot reach the proxy

The client never got a proxy to talk to. Either nothing listens at that address, the name does not resolve, or a firewall drops the packets. Chrome shows this page for all of them:

```
There is something wrong with the proxy server or the address is incorrect.
ERR_PROXY_CONNECTION_FAILED
```

Chromium’s own source describes `PROXY_CONNECTION_FAILED` (error -130) as a failure “in resolving its name, or in connecting a socket to it”, and says explicitly that it does not cover failures during CONNECT. Those get `TUNNEL_CONNECTION_FAILED` (-111) instead, per [net_error_list.h](https://chromium.googlesource.com/chromium/src/+/refs/heads/main/net/base/net_error_list.h). So the browser’s wording already tells you which hop failed.

Test the socket before you test anything else:

```
nc -vz gw.example.net 8000          # does anything accept TCP there?
dig +short gw.example.net           # does the name resolve at all?
env | grep -i _proxy                # is something else choosing the proxy for you?
```

The third line is the one people skip. A stale `HTTPS_PROXY` in a shell profile, a CI secret or a container image routes every request at a dead address, and the code you are staring at never mentions a proxy. curl confesses it in verbose mode:

```
$ HTTPS_PROXY=http://127.0.0.1:46999 curl -sv https://localhost:46443/
* Uses proxy env variable HTTPS_PROXY == 'http://127.0.0.1:46999'
*   Trying 127.0.0.1:46999...
* connect to 127.0.0.1 port 46999 from 127.0.0.1 port 56718 failed: Connection refused
* Failed to connect to localhost:46443 over proxy 127.0.0.1 after 0 ms: Could not connect to server
```

requests reads the same variables by default. Setting `Session.trust_env = False` turned that failure into a 200 in our test, and `NO_PROXY=localhost` or `curl --noproxy '*'` did the same for curl. The rules for which variable wins are in [HTTP_PROXY, HTTPS_PROXY and NO_PROXY explained](/guides/proxy-environment-variables/).

The opposite surprise also happens: a proxy you configured is silently not used. Node’s built-in fetch ignored `HTTPS_PROXY` pointing at a dead port and connected directly, until we set `NODE_USE_ENV_PROXY=1`, a variable the [Node.js CLI docs](https://nodejs.org/api/cli.html#node_use_env_proxy1) list as added in v24.0.0 and v22.21.0. Chrome skipped the proxy for `localhost` until we passed `--proxy-bypass-list="<-loopback>"`. Both explain the “works in curl, fails in the app” report, and its mirror image. Node specifics are in [Using proxies in Node.js](/guides/proxies-in-nodejs/).

## Cause 3: the right address, the wrong protocol

The proxy is up, but the client speaks a different protocol to it than the one it expects. Three variants turned up.

**An https:// proxy URL for a plain HTTP proxy.** The client starts a TLS handshake and the proxy replies in plain HTTP:

```
curl: (35) TLS connect error: error:0A00010B:SSL routines::wrong version number
```

urllib3 recognises this case and says so inside the requests exception: `Unable to connect to proxy. Your proxy appears to only use HTTP and not HTTPS, try changing your proxy URL to be HTTP.` The [urllib3 advanced usage page](https://urllib3.readthedocs.io/en/latest/advanced-usage.html) it links to has the same advice. The scheme in a proxy URL describes how you talk to the proxy, not the site. An HTTPS site through an HTTP proxy is normal and still encrypted end to end, because the TLS runs inside the [CONNECT](/glossary/http-connect/) tunnel.

**An address that is a web server, not a proxy.** Point a client at an ordinary site’s port and the CONNECT request gets a web server’s answer. Python’s built-in server replied `501 Unsupported method ('CONNECT')`; curl printed `CONNECT tunnel failed, response 501`. Other web servers may answer 400, 404 or 405 at that point. The meaning does not change: wrong port, or a gateway hostname copied from the wrong field.

**A SOCKS URL aimed at an HTTP proxy port, or the reverse.** This one fails silently. curl sent a SOCKS5 greeting to Squid’s HTTP port, Squid waited for an HTTP request line, and nothing happened until our 8-second cap: `curl: (28) Connection timed out after 8000 milliseconds`. Python failed earlier, on a missing dependency: requests raised `InvalidSchema: Missing dependencies for SOCKS support.` and httpx raised `ImportError: Using SOCKS proxy, but the 'socksio' package is not installed.` Install `requests[socks]` or `httpx[socks]`, as both projects’ docs say, then use the scheme your provider documents for that port. The difference between the two protocols is covered under [SOCKS5](/glossary/socks5/).

## Cause 4: the proxy refused the tunnel by policy (403)

The proxy understood you, knew who you were, and declined. Our open Squid port answered a CONNECT to port 46444 with:

```
HTTP/1.1 403 Forbidden
X-Squid-Error: ERR_ACCESS_DENIED 0

Access Denied.
Access control configuration prevents your request from being allowed at this time.
```

Nothing was wrong with the credentials or the target. Squid’s documented default configuration contains `http_access deny CONNECT !SSL_ports` ([http_access](https://www.squid-cache.org/Doc/config/http_access/)), and its default `acl SSL_ports port 443` lists a single port ([acl](https://www.squid-cache.org/Doc/config/acl/)). That follows [RFC 9110 section 9.3.6](https://www.rfc-editor.org/rfc/rfc9110.html#section-9.3.6), which says proxies supporting CONNECT should restrict it to known ports, and gives a CONNECT to port 25 relaying spam as the reason. Tunnelling to a database, SSH, SMTP or an unusual HTTPS port through a corporate or commercial proxy hits this rule first.

The fix belongs to whoever runs the proxy: an allowed port, an allowed destination, or a different product. A commercial gateway can also refuse a destination under its own usage policy. Its error documentation, not the status number, tells you which rule you hit.

## Cause 5: the proxy could not reach the destination (502, 503, 504)

Your hop worked. The proxy’s hop to the site did not, and the proxy wrote you an error page saying so. Squid’s pages name the failure in an `X-Squid-Error` header and in plain text:

```
HTTP/1.1 503 Service Unavailable
X-Squid-Error: ERR_CONNECT_FAIL 61
Connection to 127.0.0.1 failed.
The system returned: (61) Connection refused

HTTP/1.1 503 Service Unavailable
X-Squid-Error: ERR_DNS_FAIL 0
Unable to determine IP address from host name no-such-host.invalid
The DNS server returned: Name Error: The domain name does not exist.

HTTP/1.1 502 Bad Gateway
X-Squid-Error: ERR_ZERO_SIZE_OBJECT 0
Zero Sized Reply
Squid did not receive any data for this request.

HTTP/1.1 504 Gateway Timeout
X-Squid-Error: ERR_READ_TIMEOUT 0
Read Timeout
```

The 504 arrived 4.68 seconds after the request, with `read_timeout 4 seconds` in our config. When an upstream hangs, the delay you see is the proxy’s timeout, not the site’s response time.

Status numbers for these failures are not consistent across software. [RFC 9209](https://www.rfc-editor.org/rfc/rfc9209.html) defines a `Proxy-Status` header with named error types and a recommended status for each. Here is what the two proxies we ran sent instead:

| Upstream failure | RFC 9209 type | Recommended status | Squid 6.13 sent | Apache 2.4.67 sent |
| --- | --- | --- | --- | --- |
| Connection refused | connection_refused | 502 | 503 ERR_CONNECT_FAIL | 503 Service Unavailable |
| DNS name does not exist | dns_error | 502 | 503 ERR_DNS_FAIL | 500 Proxy Error |
| Closed with no response | connection_terminated | 502 | 502 ERR_ZERO_SIZE_OBJECT | 502 Proxy Error |
| No data before the read timeout | connection_read_timeout | 504 | 504 ERR_READ_TIMEOUT | 502 Proxy Error |
| Denied by proxy policy | http_request_denied | 403 | 403 ERR_ACCESS_DENIED | — |

Neither server emitted `Proxy-Status` in these tests. The practical rule: never diagnose from the number alone. Read the error page body, the vendor header, or the proxy’s log line.

One trap cost us a rerun. Squid connected to `localhost` over `::1`, our origin listened on IPv4 only, and the page said `Connection to ::1 failed.` A target that works from your laptop can fail through a proxy simply because the proxy prefers [IPv6](/glossary/ipv6/) and the service does not listen on it.

To fix this class: confirm the target is up from somewhere other than the proxy, then from the proxy’s network if you can. If it is transient, retry with a cap and jitter, and honour [Retry-After](/glossary/retry-after/) when the proxy sends one. If it is one exit failing while others succeed, the exit is the problem, not your code.

## When a website shows “Proxy Error”

This is the page from the top of this article, seen from the site owner’s side. Apache’s mod_proxy produced three variants on our rig, and its error log explained each one:

| Backend behaviour | Status line | Page reason | Error log |
| --- | --- | --- | --- |
| Closes the connection without a byte | 502 Proxy Error | Error reading from remote server | AH01102: error reading status line from remote server |
| Accepts, never answers (timeout=3) | 502 Proxy Error | Error reading from remote server | (70007)The timeout specified has expired |
| Hostname does not resolve | 500 Proxy Error | DNS lookup failure for: no-such-host.invalid | AH00898: DNS lookup failure for |
| Port refuses connections | 503 Service Unavailable | The server is temporarily unable to service your request | AH00957: http: attempt to connect to 127.0.0.1:46999 (127.0.0.1:46999) failed |

The timeout row answered after 3.00 seconds, matching the `timeout=3` we set on that `ProxyPass`. Note that the visitor sees an identical page for a crashed backend and a slow one. Only the log separates them.

**Visitor:** retry later, try another page on the same site to see whether the whole backend is down, and report it if it persists. Switching browsers, clearing cookies or changing your own proxy will not help, because the failure is between the site’s proxy and the site’s application.

**Owner:** grep the error log for the AH code, check the backend process and its port, and compare its normal response time with `ProxyTimeout` or the per-route `timeout=`; the [mod_proxy documentation](https://httpd.apache.org/docs/2.4/mod/mod_proxy.html) says `ProxyTimeout` defaults to the server’s general `Timeout`. Cloudflare, which is a reverse proxy too, uses its own codes for them, among them 521 (web server is down), 522 (connection timed out), 524 (a timeout occurred) and 526 (invalid SSL certificate), per its [5xx reference](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/).

## Cause 6: TLS interception

Some proxies, usually corporate ones or security appliances, decrypt HTTPS, inspect it, and re-encrypt it with a certificate they mint on the spot. Your client checks that certificate, does not recognise the issuer, and stops. Through Squid’s bumping port:

```
curl: (60) SSL certificate OpenSSL verify result: self-signed certificate in certificate chain (19)
requests.exceptions.SSLError: ... [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1010)
TypeError: fetch failed   cause: SELF_SIGNED_CERT_IN_CHAIN
net::ERR_CERT_AUTHORITY_INVALID   (Chrome: "Your connection is not private")
```

The proxy itself answered CONNECT with 200, which is why `proxycheck.sh` printed `proxy_CONNECT=200` next to `curl_exit=60`. Confirm by comparing the issuer with and without the proxy:

```
$ echo | openssl s_client -proxy 127.0.0.1:46132 -connect localhost:46443 -servername localhost 2>/dev/null | openssl x509 -noout -issuer
issuer=CN=Lab Intercepting Proxy CA

$ echo | openssl s_client -connect localhost:46443 -servername localhost 2>/dev/null | openssl x509 -noout -issuer
issuer=CN=Lab Origin CA
```

If the issuer changes, something between you and the site is re-signing traffic. When that is your employer’s sanctioned inspection proxy, trust its CA explicitly for the tools that need it. Each of these turned the failure into `hello from origin` on our rig:

```
curl --cacert corp-proxy-ca.pem -x http://proxy.corp.example:3128 https://site.example/
REQUESTS_CA_BUNDLE=/path/corp-proxy-ca.pem python app.py      # requests
httpx.Client(proxy=PROXY, verify="/path/corp-proxy-ca.pem")   # httpx
NODE_EXTRA_CA_CERTS=/path/corp-proxy-ca.pem node app.mjs      # Node
```

The [requests documentation](https://requests.readthedocs.io/en/latest/user/advanced/) describes `REQUESTS_CA_BUNDLE` as overriding the default bundle, so point it at a file that also holds the public roots if the same process talks to other sites. Do not reach for `curl -k` or `verify=False` as the fix. They hide interception you did not agree to just as well as the kind you did. Sites that pin certificates will keep failing behind an intercepting proxy whatever you trust; see [certificate pinning](/glossary/certificate-pinning/) and [TLS interception](/glossary/tls-interception/).

## Cause 7: the proxy hung up or went silent

A proxy that accepts the connection and then closes it gives the vaguest errors of all:

```
curl: (56) Proxy CONNECT aborted                 # https target
curl: (52) Empty reply from server               # http target
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
httpx.RemoteProtocolError: Server disconnected without sending a response.
net::ERR_EMPTY_RESPONSE
```

Node’s fetch did not fail at all. It waited until our own `AbortSignal.timeout(6000)` fired and then threw `TimeoutError: The operation was aborted due to timeout`. A proxy that accepts and never speaks behaves the same in every client: curl ends with `(28) Connection timed out after 5001 milliseconds` only because we passed `-m 5`.

Candidates to rule out: a protocol mismatch from cause 3, a proxy at its connection limit, and a load balancer in front of the proxy dropping idle connections. Set a timeout on every proxied request, log the exit and the time to failure, and compare against a second exit before blaming the target.

## Cloudflare 10xx errors behind a proxy

A page that says “Error 1020” or “Error 1015” with a Ray ID is not from your proxy. Cloudflare sits in front of the site as a reverse proxy and generated the page at its edge because of a setting the site owner chose. Summarised from Cloudflare’s own pages for each code:

| Code | Cloudflare’s title | Visitor side | Site owner side |
| --- | --- | --- | --- |
| 1003 | [Access Denied: Direct IP Access Not Allowed](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-1xxx-errors/error-1003/) | The request went to a Cloudflare IP address instead of the domain name. Use the hostname in the URL. | — |
| 1005 | [Access Denied: Autonomous System Number (ASN) banned](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-1xxx-errors/error-1005/) | The owner blocked the network your IP belongs to. Send the owner a screenshot of the error. | Search Security Events for the Ray ID and decide whether that [ASN](/glossary/asn/) should be allowed. |
| 1006, 1007, 1008, 1106 | [Access Denied: Your IP address has been banned](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-1xxx-errors/error-1006/) | The owner blocked your client IP. Ask them to review it. | Review the security settings that blocked the IP. Cloudflare says its support cannot override them. |
| 1009 | [Access Denied: Country or region banned](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-1xxx-errors/error-1009/) | The owner blocked the country or region of your IP address. Contact the owner. | Check the IP Access rules for the reported address. |
| 1010 | [The owner of this website has banned your access based on your browser’s signature](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-1xxx-errors/error-1010/) | Blocked on the client’s browser signature. Notify the owner. | Browser Integrity Check can be turned off in Security Settings. |
| 1015 | [You are being rate limited](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-1xxx-errors/error-1015/) | Wait, then try again. Cloudflare warns that retrying repeatedly in a short period may extend the block. | Review the [rate limiting](/glossary/rate-limiting/) thresholds. |
| 1020 | [Access denied](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-1xxx-errors/error-1020/) | A security rule with a Block action matched. Send the owner a screenshot with the Ray ID. | Find the rule in Security Events and update it. Cloudflare returns 1020 with HTTP 403. |

Two details from those pages matter when you are debugging through a proxy. Cloudflare states that requests blocked by WAF custom or managed rules do not get a 1020; they get the WAF block response instead, so the absence of a 1020 does not mean no rule fired. And every one of these codes is the site owner’s decision about traffic like yours. The legitimate path is the owner: contact them with the Ray ID, use an official API if one exists, or slow down for 1015. Rotating exits to keep hitting a site that has said no is how a rate limit turns into a ban.

## Cause to fix, in one table

| Cause | Tell-tale text | Diagnostic | Fix |
| --- | --- | --- | --- |
| Proxy credentials | response 407, Proxy-Authenticate | curl -sv -x …, then read the Proxy-Authenticate line | Correct password, port and username parameters; percent-encode or use --proxy-user |
| Special characters in the URL | Could not resolve proxy: plus a fragment of your password | Print the parsed host: python3 -c "from urllib.parse import urlsplit; print(urlsplit(URL).hostname)" | quote(password, safe='') |
| Proxy unreachable | ERR_PROXY_CONNECTION_FAILED, Could not connect to server | nc -vz host port, dig +short host | Correct host and port, open the firewall, start the proxy |
| Stale proxy settings | Uses proxy env variable HTTPS_PROXY | printenv HTTPS_PROXY https_proxy HTTP_PROXY ALL_PROXY | Unset it, add NO_PROXY, or trust_env = False |
| Wrong proxy scheme | wrong version number, appears to only use HTTP | Try the same proxy with http:// | Use the scheme the proxy speaks, not the site’s |
| Not a proxy port | response 501, 400, 404, 405 on CONNECT | curl -v http://host:port/ without -x | Use the documented gateway host and port |
| SOCKS and HTTP mixed up | A hang, or Missing dependencies for SOCKS support | Check which protocol the port speaks | Match the scheme; install requests[socks] or httpx[socks] |
| Port or destination not allowed | response 403, ERR_ACCESS_DENIED | Same request to port 443 | Ask the proxy operator to allow it, or use another route |
| Destination unreachable from the proxy | 502, 503, 504 with a proxy error page | Read X-Squid-Error or the page reason | Fix or wait for the target; retry with backoff |
| Reverse proxy backend down | 502 Proxy Error, Bad Gateway | Server error log (AH01102, AH00957) | Owner restarts or fixes the backend, tunes the timeout |
| TLS interception | self-signed certificate in certificate chain | openssl s_client -proxy and compare issuers | Trust the sanctioned CA explicitly; never disable verification |
| Proxy hung up | Proxy CONNECT aborted, Empty reply | proxycheck.sh against a second exit | Timeouts on every request; check connection limits |
| Cloudflare 10xx | Error 10xx and a Ray ID | None on your side; the code names the rule type | Contact the site owner; wait out 1015 |

## Turning exceptions into a cause in Python

httpx keeps the proxy’s status in a separate exception class, which makes it easy to log the failing hop instead of a stack trace. Tested with httpx 0.28.1 against the rig above:

```
import sys, httpx

def classify(proxy: str, url: str, verify=True) -> str:
    try:
        r = httpx.get(url, proxy=proxy, timeout=15, verify=verify)
        return f"target answered {r.status_code}"
    except httpx.ProxyError as e:          # proxy answered CONNECT with a non-2xx status
        return f"proxy refused the tunnel: {e}"
    except httpx.ConnectTimeout:
        return "timed out reaching the proxy or the target"
    except httpx.ConnectError as e:        # proxy unreachable, DNS, or TLS verification
        msg = str(e)
        if "CERTIFICATE_VERIFY_FAILED" in msg:
            return f"TLS verification failed (interception or bad cert): {msg}"
        return f"could not reach the proxy: {msg}"
    except httpx.RemoteProtocolError as e:  # proxy or target hung up mid-exchange
        return f"connection closed without a response: {e}"

if __name__ == "__main__":
    print(classify(sys.argv[1], sys.argv[2]))
```

```
$ python classify.py http://127.0.0.1:46999 https://localhost:46443/
could not reach the proxy: [Errno 61] Connection refused
$ python classify.py http://127.0.0.1:46128 https://localhost:46443/
proxy refused the tunnel: 407 Proxy Authentication Required
$ python classify.py http://127.0.0.1:46140 https://localhost:46443/
connection closed without a response: Server disconnected without sending a response.
$ python classify.py http://127.0.0.1:46132 https://localhost:46443/
TLS verification failed (interception or bad cert): [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1010)
```

With requests the same information is there, but nested: the proxy’s status line sits inside the message as `Tunnel connection failed: 407 Proxy Authentication Required`, under `requests.exceptions.ProxyError`. Matching on that substring works across the versions we ran.

## Frequently asked questions

### What does "Proxy Error" mean on a website?

It is the error page of a reverse proxy in front of the site; the exact wording "Proxy Error" with "Error reading from remote server" comes from Apache httpd's mod_proxy. The proxy could not get a valid answer from the application behind it. A visitor can only retry later; the owner has to check the backend and the proxy's error log.

### Is a proxy error my fault or the website's?

Check whether the proxy answered your CONNECT request. With curl, -w '%{http_connect}' prints 000 when you never reached the proxy, 407 or 403 when the proxy refused you, and 200 when the tunnel opened and the failure came later, from TLS or from the site.

### What is the difference between ERR_PROXY_CONNECTION_FAILED and ERR_TUNNEL_CONNECTION_FAILED?

Chromium uses ERR_PROXY_CONNECTION_FAILED (-130) when it cannot resolve or connect to the proxy itself, and ERR_TUNNEL_CONNECTION_FAILED (-111) when the proxy answered but the CONNECT tunnel was not established. In our tests a 403, a 501 and a 503 from the proxy all produced the second one.

### Why does curl say "CONNECT tunnel failed, response 407"?

The proxy wants credentials it did not receive or did not accept. Check the password, the port and any parameters packed into the username, and percent-encode special characters or pass the credentials with --proxy-user.

### What does "proxy error 429" mean in an app?

When an app shows a proxy error with a status code, that code came from a server it reached through a proxy or gateway. 429 is Too Many Requests, defined in RFC 6585: the service rate-limited you. Slow down and honour Retry-After instead of switching proxies.

### Can I fix a Cloudflare 1020 or 1015 error myself?

Nothing on your side changes the rule. Cloudflare's documentation says a 1020 means a security rule set by the site owner blocked the request, and a 1015 means the owner's rate limit was exceeded. Send the owner the Ray ID for a 1020, and wait before retrying a 1015, because Cloudflare warns that repeated attempts can extend the block.

## Sources

1. [RFC 9110: HTTP Semantics (CONNECT 9.3.6, 407 15.5.8, 502-504 15.6)](https://www.rfc-editor.org/rfc/rfc9110.html)
2. [RFC 9209: The Proxy-Status HTTP Response Header Field](https://www.rfc-editor.org/rfc/rfc9209.html)
3. [RFC 3986 section 3.2.1: User Information](https://www.rfc-editor.org/rfc/rfc3986.html#section-3.2.1)
4. [RFC 6585 section 4: 429 Too Many Requests](https://www.rfc-editor.org/rfc/rfc6585.html#section-4)
5. [RFC 6761 section 6.4: the reserved .invalid domain](https://www.rfc-editor.org/rfc/rfc6761.html#section-6.4)
6. [Chromium net_error_list.h](https://chromium.googlesource.com/chromium/src/+/refs/heads/main/net/base/net_error_list.h)
7. [libcurl error codes](https://curl.se/libcurl/c/libcurl-errors.html)
8. [Squid configuration directive: http_access](https://www.squid-cache.org/Doc/config/http_access/)
9. [Squid configuration directive: acl](https://www.squid-cache.org/Doc/config/acl/)
10. [Apache HTTP Server 2.4: mod_proxy](https://httpd.apache.org/docs/2.4/mod/mod_proxy.html)
11. [urllib3 advanced usage: HTTPS proxy error with an HTTP proxy](https://urllib3.readthedocs.io/en/latest/advanced-usage.html)
12. [Requests advanced usage: proxies, SOCKS and CA bundles](https://requests.readthedocs.io/en/latest/user/advanced/)
13. [HTTPX: proxies and SOCKS support](https://www.python-httpx.org/advanced/proxies/)
14. [Node.js CLI: NODE_USE_ENV_PROXY](https://nodejs.org/api/cli.html#node_use_env_proxy1)
15. [Linux asm-generic/errno.h](https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/errno.h)
16. [Cloudflare: 1xxx errors](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-1xxx-errors/)
17. [Cloudflare: Error 1003](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-1xxx-errors/error-1003/)
18. [Cloudflare: Error 1005](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-1xxx-errors/error-1005/)
19. [Cloudflare: Errors 1006, 1007, 1008 or 1106](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-1xxx-errors/error-1006/)
20. [Cloudflare: Error 1009](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-1xxx-errors/error-1009/)
21. [Cloudflare: Error 1010](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-1xxx-errors/error-1010/)
22. [Cloudflare: Error 1015](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-1xxx-errors/error-1015/)
23. [Cloudflare: Error 1020](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-1xxx-errors/error-1020/)
24. [Cloudflare: 5xx errors](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/)
