SOCKS5 Proxy Error Codes Explained

A SOCKS5 server can return a reply before your client reaches the website. Identify the negotiation or connection step that failed, then check the corresponding setting on the proxy or destination.

Green, amber and red status lights on a network module between rack servers

Identify where the SOCKS5 connection failed

First check which connection reported the error. The client opens a TCP connection to the SOCKS5 gateway and offers the authentication methods it supports. The gateway chooses a method, and the two sides finish any required authentication. The client then requests a connection to the destination. The gateway’s reply to that request carries a numeric reply field called REP. When the reply indicates success, the application can send its own traffic through the established connection.

An HTTPS request adds another stage. The client negotiates TLS with the destination through the SOCKS5 connection, and the destination can then send an HTTP response. A browser or HTTP library may show an error for any of these stages. Record the original message before changing the proxy address or password. The stage helps you decide which connection to check. SOCKS5 negotiation and request format.

Read the SOCKS5 reply code

The codes below apply to the SOCKS5 request reply. Hexadecimal notation such as 0x05 and a decimal value of 5 can refer to the same reply byte. Confirm that your tool is reporting REP before using the table. Library error numbers and HTTP statuses use their own code sets. The checks are for a proxy and destination you are authorized to test.

ReplyMeaningWhat to check
0x00The proxy opened the connection.Continue with TLS and the HTTP response for an HTTPS destination.
0x01The proxy reported a general failure.Give the operator the time, destination and port so they can check server logs.
0x02A proxy rule denied the request.Ask the operator to confirm that the account, destination and port are authorized.
0x03The destination network was unreachable.Have the operator check the gateway’s route and address family for that destination.
0x04The destination host was unreachable.Check the destination hostname and determine which side resolved it. Confirm the result with the proxy operator.
0x05The outbound connection was refused.Confirm the destination port and whether its service accepts connections from the proxy’s network.
0x06The packet’s time to live expired.Ask the operator to investigate routing on the destination path.
0x07The proxy does not support the requested SOCKS command.Check whether the client requested CONNECT or another command, such as UDP ASSOCIATE.
0x08The proxy does not support the supplied address type.Check whether the gateway accepts a hostname, IPv4 address or IPv6 address for the requested connection.

RFC 1928 leaves higher reply values unassigned. If the gateway reports a generic or unfamiliar code, save the exact client message and ask the provider what their implementation returns in that case. Two providers can report the same underlying network failure differently. Standard SOCKS5 reply values.

Separate authentication and protocol errors from reply codes

The gateway can reject all offered authentication methods before it receives a destination request. At that stage, 0xFF is the method selection response. Check whether the endpoint requires username and password, whether the client supports that method, and whether you used the correct listener. When the gateway accepts the username and password method but returns a nonzero authentication status, it has rejected that authentication attempt. Check the credentials against the exact product and gateway. The username and password subnegotiation has a version byte of its own. SOCKS5 username and password authentication.

A bad version message can appear when a SOCKS client connects to an HTTP proxy port. Verify the advertised protocol and port together. A local message that the connection to the gateway was refused occurs before SOCKS negotiation. That points to the gateway address and listening port. A 0x05 reply means the SOCKS gateway was reachable and reported refusal for the next hop. An HTTP 407 is an HTTP proxy authentication challenge. If it appears while you expect SOCKS5, check which protocol and endpoint the client actually selected.

Diagnose a SOCKS5 proxy error with cURL

Run a single request to a known endpoint. Replace the example gateway with an approved SOCKS5 endpoint you manage. This example assumes it accepts your connection without a password prompt. If it needs credentials, use your client’s approved secret configuration. On Windows, use curl.exe if your shell assigns another command to curl.

curl --disable --noproxy "localhost" --proxy "socks5h://gateway.example:1080" --silent --show-error --max-time 15 --write-out "\nhttp=%{http_code}\n" "https://testmyproxies.com/api/my-ip"

The command uses socks5h to ask the gateway to resolve the lookup hostname. On success, expect a JSON response with an ip field and http=200. If cURL shows http=000, it has no destination HTTP status to report. Read the accompanying cURL error first. Modern cURL can report exit code 97 for a proxy handshake failure. A libcurl application can call CURLINFO_PROXY_ERROR for the more specific library error. Its numeric value is a libcurl enum. Compare the enum name with the message or the documented SOCKS5 reply. libcurl error codes. Detailed SOCKS proxy errors in libcurl.

For example, curl: (5) Could not resolve proxy means cURL could not look up the gateway’s hostname. Investigate DNS in the environment where cURL runs. A report of SOCKS5 reply 0x05 points to the connection from that gateway to the destination. Check the destination’s listening port and access rules with its operator.

If the test succeeds and one destination still fails, repeat against the destination you control. Keep the proxy, credentials and client location the same. A hostname failure can depend on where resolution happens. Compare the two DNS modes as a separate test, then include the time, proxy protocol, destination and sanitized error in any support request. Compare SOCKS5 and SOCKS5h DNS resolution. More cURL proxy tests.

All proxy testing guides · Open the proxy tester