cURL Proxy Error Codes Explained

Published

Find the exit code and the two HTTP statuses

When cURL prints curl: (7), the number is a cURL exit code. Keep it alongside the error message. With an HTTP proxy and an HTTPS destination, also record the proxy’s CONNECT status and the destination’s HTTP status. Replace the example proxy with an endpoint you are authorized to use.

curl --disable --noproxy "localhost" --proxy "http://gateway.example:8080" --silent --show-error --max-time 15 --output /dev/null --write-out "CONNECT %{http_connect} | Target %{http_code}\n" "https://testmyproxies.com/api/my-ip"
printf 'cURL exit code: %s\n' "$?"

In PowerShell, run the first line with curl.exe and replace /dev/null with NUL. Read $LASTEXITCODE immediately afterwards. The command keeps HTTP error responses visible so you can diagnose them. An HTTP response such as 403 can therefore appear alongside exit code 0. With --fail enabled, an HTTP error can make cURL exit with 22. A displayed HTTP status of 000 means cURL recorded no HTTP response at that stage. cURL response variables.

What each error code tells you

Exit codeWhat to check
5 Proxy hostname lookup failedResolve the proxy hostname from the machine where cURL runs. Confirm the resolver and the network required to reach it.
7 Connection failedCheck the host and port cURL names in its error. For a proxy connection, confirm the gateway address and test TCP reachability from the same machine.
28 TimeoutCheck the last stage reached and the timeout options. A retained CONNECT 200 points to a later stage than an unanswered CONNECT.
35 TLS connection failedCheck whether TLS failed while connecting to an HTTPS proxy or after the CONNECT tunnel opened. Compare the configured scheme with the actual listener.
56 Failure receiving dataRead the error message and CONNECT status. A rejected CONNECT or a closed connection can result in this exit code. If cURL shows CONNECT 407, investigate the proxy challenge.
60 Peer verification failedCheck the failing peer name, certificate chain and trust store used by this cURL build. Keep certificate verification enabled while you diagnose it.
97 Proxy handshake errorRead the rest of the message. With SOCKS5, compare the selected proxy scheme, authentication method and the reply from the gateway. Read SOCKS5 reply codes.

Use the combination to find the next check

Suppose cURL reports CONNECT 407 | Target 000 and exits with 56. Start with the proxy’s authentication requirements, since the tunnel was rejected before the destination responded. If cURL instead reports CONNECT 200 | Target 000 and exits with 60, the proxy accepted the tunnel. Investigate verification of the certificate cURL received through it. If the message names an HTTPS proxy before any CONNECT response, check the proxy’s certificate first. Read proxy and website challenges · Trace the TLS connection that failed.

When sending results to support, include the cURL version, approximate time, proxy type, exit code and both HTTP statuses. Keep proxy passwords and authorization headers out of shared output. cURL exit code reference.

All proxy testing guides · Open the proxy tester