Guide · Proxy basics
curl: (56) CONNECT tunnel failed, response 407: fix it in curl and every client
curl: (56) CONNECT tunnel failed, response 407 means curl asked the proxy to open a tunnel to an HTTPS site and the proxy refused because the credentials were missing or wrong. Exit code 56 is curl's generic receive error; the number after "response" is the proxy's own status, so 501 or 502 in the same message mean something else entirely. curl 7.86.0 and older, including the 7.81.0 that Ubuntu 22.04 ships, print the same failure as curl: (56) Received HTTP code 407 from proxy after CONNECT. Fix a 407 by sending the exact username and password with -U user:pass or URL-encoding special characters inside -x. What 407 itself means is covered under proxy authentication; this page is about recognising it in curl and in six other clients.
Reviewed 8 Nov 2026
The short answer
- Reproduced with curl 8.7.1: a wrong password and no password both gave
curl: (56) CONNECT tunnel failed, response 407, exit 56,%{http_connect}= 407. - For a plain
http://URL there is no tunnel: curl exits 0 and the 407 is the response code. - An unencoded
@or:in the password gives a different error first:curl: (5) Unsupported proxy syntax. - Other numbers in the same message:
501= the port is a web server, not a proxy;502= the proxy could not reach the site. - Older curl words it differently: up to 7.86.0 the message is
Received HTTP code 407 from proxy after CONNECT, from 7.87.0 on it isCONNECT tunnel failed, response 407. Same exit code 56, same fix. - In Python and Node the same 407 surfaces as
ProxyError,ClientHttpProxyError,TunnelErrororfetch failed; the table below has the exact text.
Fix the 407 in curl
- Copy the username and password again. On ARC's rotating gateway the username also carries targeting tokens such as
_pool-arcfast_country-de, so a typo in a token is a wrong username. - Pass credentials with
-U(--proxy-user) to avoid URL-parsing problems:curl -U 'user:p@ss:w0rd' -x http://host:port https://example.com/returned 200 in our test. - Or URL-encode them inside
-x:@becomes%40,:becomes%3A. The encoded form returned 200; the raw formhttp://arc2:p@ss:w0rd@127.0.0.1:18080failed withcurl: (5) Unsupported proxy syntax ... Port number was not a decimal number between 0 and 65535. - Watch the exchange with
-v: you should seeProxy-Authorization: Basic ...on theCONNECTline. If it is missing, curl had no credentials. - If the same string also fails in the proxy tester, the credentials are wrong; if it works there, look at quoting in your shell or script.
Other numbers after "CONNECT tunnel failed, response"
| curl output (reproduced, curl 8.7.1) | Meaning |
|---|---|
curl: (56) CONNECT tunnel failed, response 407 | Credentials missing or rejected |
curl: (56) CONNECT tunnel failed, response 501 | The port belongs to a web server that does not support CONNECT, not a proxy |
curl: (56) CONNECT tunnel failed, response 502 | The proxy could not reach the target host |
curl: (56) Proxy CONNECT aborted | The proxy closed the connection without answering |
curl: (7) Failed to connect to 127.0.0.1 port 18099 ... Couldn't connect to server | Nothing listening on that host and port |
curl: (35) ... tlsv1 alert protocol version (LibreSSL) | -x https:// given for a plain HTTP proxy; see SSL: WRONG_VERSION_NUMBER |
If you omit the port in -x, curl's man page says it assumes 1080. ARC's gateway listens on 8000, so always give the port.
curl: (56) Received HTTP code 407 from proxy after CONNECT
This is the same error in older curl. Up to and including curl 7.86.0, lib/http_proxy.c reported a refused CONNECT as Received HTTP code %d from proxy after CONNECT; curl 7.87.0 (December 2022) changed the line to CONNECT tunnel failed, response %d. The exit code stayed 56 and the number is still the proxy's status, so everything on this page applies unchanged.
You still meet the old wording on long-term-support systems: Ubuntu 22.04 ships curl 7.81.0, which predates the change. Check with curl --version. The wordings below are quoted from curl's source at each version, not from a run here; the 2026-11-02 runs on this page used curl 8.7.1.
| curl 7.86.0 and older | curl 7.87.0 and newer | Meaning |
|---|---|---|
curl: (56) Received HTTP code 407 from proxy after CONNECT | curl: (56) CONNECT tunnel failed, response 407 | Credentials missing or rejected |
curl: (56) Received HTTP code 502 from proxy after CONNECT | curl: (56) CONNECT tunnel failed, response 502 | The proxy could not reach the target host |
curl: (56) Received HTTP code 501 from proxy after CONNECT | curl: (56) CONNECT tunnel failed, response 501 | Not a proxy: a web server that does not support CONNECT |
The same 407 in other clients
Reproduced on 2026-11-02 against the same local proxy with a wrong password and an HTTPS target. The integration guides linked in the first column have the setup and a retry loop that stops on 407 for each one.
| Client (version run) | What the 407 looks like | Retried by default? |
|---|---|---|
| Python requests 2.34.2, urllib3 2.8.0 | requests.exceptions.ProxyError: ... (Caused by ProxyError('Unable to connect to proxy', OSError('Tunnel connection failed: 407 Proxy Authentication Required'))) | No; a mounted Retry(total=3) sent 4 CONNECTs |
| httpx 0.28.1 | httpx.ProxyError: 407 Proxy Authentication Required | No |
| aiohttp 3.14.5 | ClientHttpProxyError: 407, message='Proxy Authentication Required', url='http://arcuser:WRONG@127.0.0.1:18080' (password included, so do not log it) | No |
| Scrapy 2.19.0 | TunnelError: Could not open CONNECT tunnel with proxy 127.0.0.1:18080 [{'status': 407, 'reason': b'Proxy Authentication Required'}] | Yes: "Gave up retrying ... (failed 3 times)" |
axios 1.21.0, proxy option | err.code ERR_BAD_REQUEST, "Request failed with status code 407", err.response.status 407 | No |
undici 7.30.1 fetch + ProxyAgent | TypeError: fetch failed, cause chain ending in Proxy response (407) !== 200 when HTTP Tunneling | No |
| Chrome via Playwright or Puppeteer | Depends on the tool; see ERR_TUNNEL_CONNECTION_FAILED | No |
With a plain-HTTP target, requests 2.34.2 and httpx 0.28.1 did not raise: they returned a response with status 407. Check the status as well as catching exceptions.
Code
Worked example
# See what the proxy answered to CONNECTcurl -sS -o /dev/null -w 'connect=%{http_connect} http=%{http_code}\n' \ -x "http://USERNAME_pool-arcfast_country-de:WRONG@proxy.arcproxies.io:8000" https://example.com/# curl: (56) CONNECT tunnel failed, response 407# connect=407 http=000# Fix: credentials via -U, no URL parsing involvedcurl -sS -o /dev/null -w 'connect=%{http_connect} http=%{http_code}\n' \ -U 'USERNAME_pool-arcfast_country-de:PASSWORD' -x "http://proxy.arcproxies.io:8000" https://example.com/# connect=200 http=200> CONNECT example.com:443 HTTP/1.1> Host: example.com:443> Proxy-Authorization: Basic YXJjdXNlcjpXUk9ORw==> User-Agent: curl/8.7.1> Proxy-Connection: Keep-Alive>< HTTP/1.1 407 Proxy Authentication Required< Proxy-Authenticate: Basic realm="test"* Authentication problem. Ignoring this.< Content-Length: 0< Connection: close<* CONNECT tunnel failed, response 407curl: (56) CONNECT tunnel failed, response 407FAQ
Questions
Something not covered? Write to contact@arcproxies.io.
What does curl: (56) CONNECT tunnel failed, response 407 mean?
The proxy refused to open an HTTPS tunnel because curl sent no credentials or wrong ones. 56 is curl's receive-error exit code; 407 is the proxy's status. Fix the username or password and pass them with -U or URL-encoded in -x.
What does curl: (56) Received HTTP code 407 from proxy after CONNECT mean?
The same as CONNECT tunnel failed, response 407: the proxy rejected missing or wrong credentials. curl 7.86.0 and older use this wording (Ubuntu 22.04 ships 7.81.0); curl 7.87.0 changed it. Fix the username or password the same way.
Why does curl say CONNECT tunnel failed, response 502 or 501?
The number is whatever the proxy returned. In our tests 502 meant the proxy could not reach the target host, and 501 meant the address was a web server rather than a proxy. Neither is a credentials problem.
How do I pass a proxy password with special characters to curl?
Use -U 'user:password' together with -x http://host:port, or URL-encode the password inside the proxy URL (@ as %40, : as %3A). An unencoded @ makes curl fail earlier with exit code 5, Unsupported proxy syntax.
Why do I get 407 with curl but not with an HTTP URL?
For http:// targets curl sends the request through the proxy without a tunnel, so a 407 is just the HTTP response code and curl exits 0. For https:// targets the 407 comes back on the CONNECT request and curl exits 56.
Does the website see the 407?
No. The 407 comes from the proxy before any connection to the site is made, and the proxy credentials are meant for the proxy only.
Sources & review
Last reviewed by the ARC Proxies team. Prices are read from the live catalog at build time.
- [1]curl: libcurl error codes (CURLE_RECV_ERROR 56, CURLE_SSL_CONNECT_ERROR 35)
- [2]curl: curl man page (--proxy, --proxy-user, -w http_connect)
- [3]curl: lib/http_proxy.c at curl 7.86.0: "Received HTTP code %d from proxy after CONNECT"
- [4]curl: lib/http_proxy.c at curl 7.87.0: "CONNECT tunnel failed, response %d"
- [5]Ubuntu: Package curl in jammy (22.04 LTS): 7.81.0
- [6]IETF: RFC 9110: HTTP Semantics, 15.5.8 407 Proxy Authentication Required
- [7]IETF: RFC 9110: HTTP Semantics, 9.3.6 CONNECT
- [8]Requests: Advanced usage: Proxies and SOCKS
- [9]HTTPX: Proxies
Next
Where to go from here
Guides