curl SOCKS5 Proxy: DNS and Exit Codes

A curl SOCKS5 proxy command should identify where destination DNS happens and which failure counts as an error. Use --socks5-hostname or a socks5h URL for proxy-side destination resolution. Use --socks5 or socks5 for local resolution. Our local experiment compares all four forms and separates protocol, timeout and HTTP failures.

21Local curl runs
4Parameter forms compared
12/12Expected HTTP markers
9/9Expected failure exits

SOCKS rejection, stalled HTTP and HTTP 503 produced different exit codes: 97, 28 and 22.

Measured

1. Choose the parameter that matches your DNS intent

The proxy address identifies the listener. The destination URL identifies the website. For a hostname destination, local resolution converts its name to an IP before the SOCKS CONNECT request. Proxy-side resolution sends the name to the listener. A hostname used for the proxy server still needs resolution on the client, regardless of the destination mode.

curl SOCKS options and their equivalent proxy URL schemes, with destination DNS location.
curl optionEquivalent proxy URLDestination DNS
--socks5 HOST:PORT--proxy socks5://HOST:PORTLocal client
--socks5-hostname HOST:PORT--proxy socks5h://HOST:PORTProxy receives the name

The h belongs to the proxy URL scheme, not the target URL. An HTTPS destination remains https://example.com/ in both modes. A SOCKS endpoint is also different from an HTTP proxy: placing an HTTP scheme before a SOCKS-only listener changes the protocol curl attempts to speak. A port such as 1080 does not identify that protocol by itself.

Run curl --version to record the actual build and TLS backend. On Windows PowerShell, use curl.exe to avoid an alias selecting another command. The generated POSIX version uses curl. For a local listener, see the SSH dynamic forwarding guide; a listener must already be running before curl can use it.

2. Generate a command with explicit limits

This builder creates a command in your browser without connecting to the entered endpoint. The target is fixed to example.com over HTTPS. Choose the DNS mode, argument style and shell, then inspect the output before running it. No credentials are collected, and the loopback default assumes you already have a local proxy.

IPv4 or DNS hostnames only; no scheme, credentials or IPv6 literal. Ports 1–65535. Timeouts 0.1–120 seconds; total must be at least connect.

Choose your endpoint and parameter form.

Your curl command will appear here.

Control configuration and bypass rules. The generated -q appears first so curl does not read its default configuration file. The explicit proxy option selects the listener, while --noproxy sets a nonmatching reserved hostname for the fixed destination. This prevents an inherited NO_PROXY entry from bypassing the example and avoids empty-argument differences in Windows PowerShell.

Read both outputs. The silent flag suppresses the progress meter, while --show-error preserves error messages. --write-out reports the HTTP response code and curl exit code. The command leaves the body visible. For automated parsing, separate the body into an output file and treat the process return code as a separate field, rather than searching the body for a success string.

Set the budget. --connect-timeout limits the connection phase, including the relevant handshakes. --max-time limits the overall transfer. The total budget includes the connection phase; it is not an extra allowance after connection. These settings differ from the connect/read tuple used by Python Requests.

For a proxy requiring authentication, curl supports --proxy-user. Supplying just the username can prompt for a password in an interactive terminal. Avoid putting credentials into shared command history, URLs or debug logs. Check the authentication methods supported by the installed build and endpoint; a credential prompt does not make a non-SOCKS listener compatible.

3. What twenty-one local runs established

We used curl 8.13.0 (Windows) libcurl/8.13.0 Schannel zlib/1.3.1 WinIDN against a temporary loopback SOCKS responder. Each of four parameter forms ran three times. Three more configurations tested SOCKS refusal, a stalled HTTP response and HTTP 503 with --fail. The responder recorded CONNECT address types and returned a fixed HTTP body; it never forwarded upstream traffic.

Twenty-one local curl runs across four parameter forms and three failure controls.
CaseRoundsObserved resultMeaning
--socks5 / socks5 URL3 + 36 markers; IP-type CONNECTLocal destination resolution
--socks5-hostname / socks5h URL3 + 36 markers; ATYP 3 localhostDestination name preserved
SOCKS REP 5 refusal3Exit 97; HTTP 000Proxy handshake failure
Accepted, then stalled HTTP3Exit 28; HTTP 000Overall timeout reached
HTTP 503 with --fail3Exit 22; HTTP 503HTTP-level error response

Local DNS selected IPv6 ::1 in this run, encoded as ATYP 4. The name-resolving forms sent localhost using ATYP 3. Both dedicated flags matched their corresponding proxy URL forms for this destination. An IP literal target would remove that name-resolution comparison, so it is not an equivalent experiment for checking how a client handles destination names.

The rejection response used SOCKS reply code 5; curl surfaced it as process exit 97 on this build. A successful SOCKS handshake followed by silence produced exit 28. HTTP 503 produced exit 22 because --fail was enabled. HTTP 000 denotes the absence of an HTTP response code here, not a response sent by the target.

Download the 21-run CSV or inspect raw commands, output and handshake records. This is a dated local HTTP experiment. It does not prove public proxy uptime, actual proxy-side DNS resolution, exit geography or HTTPS certificate handling. The generator uses HTTPS as an operational example, which was not the measured local transfer.

4. Diagnose failures before adding retries

Start with the stage that failed. A listener connection error suggests checking the host, port and process. Exit 97 requires inspecting the SOCKS exchange or endpoint compatibility. Exit 28 only says a configured operation timed out; use diagnostics to identify the slow stage. Exit 22 with an HTTP code means an HTTP response arrived and --fail classified it as an error.

Use --verbose for an inspected request when needed, and remove secrets before sharing its output. Keep destination certificate verification enabled. SOCKS5 does not encrypt its client-to-proxy hop; HTTPS still matters beyond the proxy. curl tests its own request path, not all browser traffic, WebRTC or general UDP forwarding. Inspect the observed exit separately when identity matters.

Add retries only after deciding which failures and HTTP methods are safe to repeat. A transfer can fail after a server processed a request. In scripts, record the exit status immediately after curl, avoid treating every nonzero status as a dead proxy, and keep HTTP errors separate from transport failures. The experiment data remains a static snapshot with no automatic refresh.

Reference: the official curl manual documents SOCKS options, proxy authentication, time limits and write-out variables. Check the installed version before using newer options. Shell quoting in this builder targets PowerShell or a POSIX shell; it is not a Windows cmd.exe command generator.

Verify a browser profile separately after a curl request succeeds.

Download RoxyBrowser

For a desktop browser profile workflow, review RoxyBrowser on its official site. curl options apply to curl; configure and verify the intended browser profile independently.

Frequently Asked Questions

What does --socks5-hostname change?

It sends the destination hostname in the SOCKS5 request so the proxy can resolve it. --socks5 resolves the destination locally first. The equivalent proxy URL schemes are socks5h and socks5 respectively; resolving the proxy hostname itself remains a separate step.

Why does curl ignore my explicitly configured proxy?

Check NO_PROXY and no_proxy bypass settings, the default curl configuration file and the actual executable being run. This generator places -q first and sets an explicit nonmatching bypass entry for its fixed example.com target. Inspect the command and environment before comparing results.

Does curl exit zero mean the HTTP response was successful?

Not necessarily. Without --fail, an HTTP error response can still complete a successful transfer. This page uses --fail so HTTP status 400 or above normally produces exit code 22. Inspect both the HTTP status and transfer exit code.

Can I use -k to fix a SOCKS5 connection failure?

No. -k disables destination TLS certificate verification and does not repair a refused listener, SOCKS negotiation or destination routing. Diagnose the failing phase and configure a required CA explicitly. Keep verification enabled for normal HTTPS requests.