Reading curl Proxy Errors: Exit Codes 5, 7, 28, 56 and 97

· Updated:

curl: (56) Proxy CONNECT aborted means curl reached the proxy and sent its CONNECT request, but the proxy closed the connection without answering. It is one of five exit codes that cover nearly every proxy failure, and each points at a different hop: resolving the proxy (5), connecting to it (7), waiting on it (28), the CONNECT exchange (56) or a SOCKS handshake (97). Run the command again with -v and the last few lines tell you which one you hit.

Verify any line with one curl command

Exit code lookup

Check the number with echo $? right after the command (or $LASTEXITCODE in PowerShell). Read the message as well as the number: curl 8.20.0 moved a refused CONNECT (CONNECT tunnel failed, response NNN) from code 56 to code 7, so the same proxy problem can carry a different number on different machines. Check yours with curl --version.

CodeTypical messageHop that failed
5Could not resolve proxy: HOSTDNS lookup of the proxy hostname
7Failed to connect to IP port PORT ... Couldn't connect to server; from curl 8.20.0 also CONNECT tunnel failed, response NNNTCP connection to the proxy, or (newer curl) a refused CONNECT
28Failed to connect ... Timeout was reached or Operation timed outNo answer in time, at connect or later
56Proxy CONNECT aborted; before curl 8.20.0 also CONNECT tunnel failed, response 407The CONNECT exchange with an HTTP proxy
97User was rejected by the SOCKS5 server and similarSOCKS handshake (curl 7.73.0 and later)

Code by code: the -v signature and the fix

curl (5) could not resolve proxy

Verbose output stops at * Could not resolve proxy: HOST before any Trying line. curl never found an address, so the proxy was never contacted. Check the hostname with getent hosts HOST or nslookup HOST. With numeric proxy IPs this code usually means something else supplied the proxy: look for a misspelled http_proxy, HTTPS_PROXY or ALL_PROXY variable with env | grep -i proxy. A whole ip:port:user:pass line pasted into -x tends to fail with a URL or port parsing error instead; split it first.

curl (7) failed to connect to proxy

You will see * Trying IP:PORT... followed by Connection refused or Couldn't connect to server. The host answered and nothing listens on that port, or a firewall rejected the packet. Test the socket alone with nc -vz IP PORT. Common causes: an expired proxy, a port that changed after a protocol switch, or an outbound firewall on the server you are testing from. Older curl releases, before 7.73.0, also reported SOCKS handshake failures as 7, so on an old system read the message text, not just the number. On curl 8.20.0 and later, a 7 that follows a CONNECT line in the trace is a refusal from the proxy, covered under the tunnel-failed heading below.

curl (28) timeouts

Where the clock ran out matters. If * Connected to IP never appears, the proxy did not accept the TCP connection in time; packets are probably being dropped rather than refused, which points to a wrong IP or a firewall. If the connection succeeded and the timeout came later, the proxy or the destination is slow. Separate the two limits with --connect-timeout 10 --max-time 30, and see the proxy timeout guide for network-side causes.

curl (56) Proxy CONNECT aborted

In the trace you see > CONNECT example.com:443 HTTP/1.1, then no < HTTP/1.1 reply line, then the abort. The proxy accepted TCP and hung up instead of answering. The most frequent cause is a protocol mismatch: you used http:// (or no scheme) against a port that only speaks SOCKS5, so the proxy reads an HTTP request where it expected a SOCKS greeting and drops the connection. Try the same line as socks5h://. Other causes are a proxy refusing your source address, a proxy at its connection limit, or a middlebox resetting the stream, which can also surface as Recv failure: Connection reset by peer under the same code 56.

CONNECT tunnel failed, response NNN (56, or 7 in newer curl)

Here the proxy did answer, with a refusal. curl releases before 8.20.0 exit with 56; 8.20.0 and later exit with 7, with the same message. The number in the message is the proxy's HTTP status. 407 means the login is missing or wrong; the 407 guide covers it in depth. 502 or 503 means the proxy could not reach the destination. 403 usually means the proxy's policy refused that host or port.

curl (97) proxy handshake failed

Code 97 is reserved for proxy handshake errors and appears with SOCKS proxies. The message names the step. No authentication method was acceptable means the server requires a login you did not send. User was rejected by the SOCKS5 server means the username or password is wrong. cannot complete SOCKS5 connection to HOST (worded Can't complete in older releases) means the proxy could not open the destination. A complaint about an invalid version in the initial SOCKS5 response means the port is not speaking SOCKS5 at all, usually because it is set to HTTP only.

407 replies that do not fail the command

A 407 only fails the command for https:// targets, where curl must tunnel (exit 56, or 7 from curl 8.20.0). For a plain http:// URL, the proxy's 407 page is a normal response: curl prints it and exits with 0, which makes a broken login look like success in a script. Add --fail (exit 22 on HTTP errors) and print the status explicitly:

curl -s -o /dev/null --fail -w '%{http_code}\n' \
  -x http://IP:PORT -U 'USER:PASS' http://example.com

In the -v output, check for a > Proxy-Authorization: Basic line before the 407. If it is missing, curl sent no credentials at all, which points at the command or the variable that built it, not the password.

Flags that change the outcome

--proxy-user and special characters

-U 'USER:PASS' (long form --proxy-user) keeps credentials out of the proxy URL, so @, # or : in a password need no percent-encoding. Single quotes stop the shell from expanding $ or !. If you prefer the URL form, encode the password: @ becomes %40.

socks5:// versus socks5h://

With socks5://, curl resolves the destination hostname locally and hands the proxy an IP address. With socks5h://, the proxy resolves it. Use socks5h:// unless you have a reason not to: it avoids local DNS leaks and fixes destinations your local resolver cannot see.

--proxy-insecure is not -k

-k skips certificate checks for the destination site. --proxy-insecure skips them for the proxy itself, and only matters when the proxy URL starts with https://, meaning TLS to the proxy. Neither helps when you wrote https:// for a plain HTTP proxy; that fails with exit 35 and a wrong version number message. Change the proxy scheme to http://; the site's own HTTPS still runs end to end through the tunnel.

Verify a proxy line before you depend on it

The simplest way to keep all five codes out of production is to test each line once with a command that reports the exit IP:

curl -sS --connect-timeout 10 -m 30 -x http://IP:PORT -U 'USER:PASS' \
  https://proxyv4.com/api/my-ip; echo " exit=$?"

A printed address equal to the proxy IP and exit=0 means resolution, connection, login and tunnel all work. For batches without a shell loop, the proxy checker runs the same test on a pasted list. The cURL setup guide has the full command set, including timing checks.

When you buy, buy so this test stays boring. ProxyV4 private datacenter IPv4 proxies arrive as one ip:port:user:pass line, support HTTP(S) and SOCKS5 with username and password, and let you run both protocols on the same port from the order page, which removes the protocol mismatch behind many code 56 and 97 errors. The IP stays the same when renewed before expiry, and traffic is not metered. They will not suit you if you need UDP without checking with support first, or a fresh IP on every request. Live per-IP prices are on the pricing page; order one IP, run the command above, then scale.

Triage in a script

If you test many proxies, map the exit code to the hop instead of logging raw numbers:

while IFS=: read -r ip port user pass; do
  curl -s -o /dev/null --connect-timeout 10 -m 30 \
    -x "http://$ip:$port" -U "$user:$pass" https://example.com
  case $? in
    0)  r="ok" ;;
    5)  r="proxy name did not resolve" ;;
    7)  r="refused: wrong port, proxy down, or CONNECT rejected (curl 8.20+)" ;;
    28) r="timeout" ;;
    56) r="CONNECT refused or aborted: check login and protocol mode" ;;
    97) r="SOCKS handshake failed" ;;
    *)  r="other" ;;
  esac
  echo "$ip:$port $r"
done < proxies.txt

Frequently asked questions

What does curl error 56 mean with a proxy?

Code 56 is a receive failure. With a proxy it almost always means the CONNECT step failed: either the proxy closed the connection (CONNECT aborted) or, in curl releases before 8.20.0, replied with an error status such as 407 or 502. Newer curl reports that second case as code 7.

Does -k fix proxy SSL errors?

Only for the destination's certificate. Certificate problems with an https:// proxy need --proxy-insecure, and a plain HTTP proxy should simply be addressed with http://.

Why does curl work but my browser does not with the same SOCKS5 proxy?

curl supports SOCKS5 username and password login, while Chrome and other Chromium browsers do not. Use the HTTP mode of the proxy in Chromium browsers.

Which curl version introduced exit code 97?

curl 7.73.0 added CURLE_PROXY (97) for proxy handshake errors. Earlier versions report most of the same SOCKS failures as code 7.

Can I switch a ProxyV4 proxy between HTTP and SOCKS5?

Yes. On the order page in the dashboard choose HTTP only, SOCKS5 only or both on the same port, then copy the line again because the port can change.

Verify any line with one curl command

ProxyV4 private IPv4 proxies come as one ip:port:user:pass line with HTTP(S) and SOCKS5 support and unmetered traffic. Order a single IP, test it with the command above, then buy more.

See live prices

Related articles

Knowledge base
Checking a Proxy: A Three-Pass Test Before Real Work
Check a proxy in three passes: does it connect, which IP and country do websites see, and is the browser leak-free. Free checker, curl commands and error fixes.
Proxy errors
Behind ERR_TUNNEL_CONNECTION_FAILED: reading the proxy's CONNECT reply
ERR_TUNNEL_CONNECTION_FAILED hides the proxy's real reply to CONNECT. Uncover the 407 or 502 behind it and fix Chrome, Puppeteer, Playwright or Android setups.
Free tools
Test whether a remote TCP port accepts connections
Free online port checker: test up to 8 TCP ports on any public IP or hostname, see open, refused or timed-out results with handshake time, debug proxy ports.
Proxy setup
Using cURL with an authenticated proxy: commands that prove it works
Send cURL requests through an authenticated HTTP(S) proxy with -x and -U, confirm the exit IP, read the CONNECT handshake and time each request on any OS.
Knowledge base
How to Fix the SSL WRONG_VERSION_NUMBER Proxy Error
Fix the SSL WRONG_VERSION_NUMBER proxy error in Python requests, curl and env vars: use an http:// proxy URL for HTTPS targets. Examples included.
Knowledge base
Proxy 403 Forbidden: Is It the Proxy or the Website?
Proxy 403 Forbidden? Find out whether the proxy or the website refused the request with one curl command, then apply the fix that matches each cause.
Knowledge base
How to Fix 429 Too Many Requests When Using a Proxy
Getting 429 Too Many Requests through a proxy? Learn who sent it, how to honor Retry-After with backoff, and when more IPs help and when they do not.
Free tools
Check proxies in bulk: status, exit IP and latency
Free online proxy checker: paste up to 100 ip:port:user:pass lines and see which proxies work, their exit IP and latency, plus what each failure result means.
Products
Dedicated datacenter proxies: one private IPv4 per customer
Private IPv4 proxies in the US, Vietnam, Japan, South Korea, Singapore, the UK and Hong Kong. One tenant per IP, HTTP(S) and SOCKS5, no traffic metering.
Products
Static ISP proxies: residential IPs on consumer networks
Static ISP proxies in 23 countries, from Germany and the UK to the US, Brazil and Japan: fixed IPs on consumer networks, one customer each, unmetered traffic.