What Happens When You Use SOCKS5 on an HTTP Proxy Port?

Published:

10 minute read

Acar Diveroli
Written by: Acar Diveroli
Tall window with a raw byte dump and a blue 48 card in front; a dashed ghost volume shows the expected 05 byte

A protocol mismatch means the scheme in the proxy URL does not match the protocol the port listens on. The scheme decides which bytes the client writes to the connection first. socks5:// sends a binary greeting, http:// sends a plain-text request. If the port expects a different language, the handshake breaks at the first step. The trap is that the error messages usually blame the network or the server. This post covers the symptoms in both directions, what the messages mean and a one-line diagnosis.

The scheme picks the first bytes

The scheme in the proxy URL decides which protocol the client speaks with the proxy. The port is only an entrance, and behind it listens either an HTTP proxy or a SOCKS5 server. Even if the rest of the URL is correct, a wrong scheme means the two sides speak different languages.

The first bytes show the difference. Our test servers logged the first two bytes they received:

SchemeClient's first bytesMeaning
socks5://, socks5h://05 03SOCKS version 5, three auth methods
http://, plain HTTP targetGEStart of a GET http://… request
http://, HTTPS targetCOStart of a CONNECT host:443 request
https://16 03Start of a TLS handshake

Under RFC 1928, the first byte of a SOCKS5 greeting is the version number, and its value must be 0x05. An HTTP proxy expects text that it reads line by line. Neither understands the other's bytes. A URL without a scheme is a separate trap: if you leave the scheme out, curl treats the address as an HTTP proxy. For the parts of the URL, see How to Read a Proxy URL.

SOCKS5 client, HTTP port

A SOCKS5 client connecting to an HTTP port sends its greeting and waits for a two-byte reply. The HTTP proxy tries to read those bytes as a request line and fails. In our test, a proxy built on Node's HTTP parser answered right away with HTTP/1.1 400 Bad Request.

The client takes the first byte of that reply as the version number. The byte is the letter H, which is 0x48. It is not the expected 0x05, so the client aborts the handshake. You never see the 400 response itself. It only shows up in the proxy log or in a raw socket test.

In our test the tools printed these messages:

  • curl 8.22.0, socks5:// and socks5h://: curl: (97) Received invalid version in initial SOCKS5 response. The message stayed the same with or without credentials and with HTTP or HTTPS targets.
  • curl, socks4://: curl: (97) SOCKS4 reply has wrong version, version should be 0.
  • Requests 2.34.2 and PySocks 1.7.1: requests.exceptions.ConnectionError, containing NewConnectionError and SOCKS5 proxy server sent invalid data.

The curl documentation defines code 97 as a proxy handshake error. The code does not say the credentials are wrong, because the handshake never reached the authentication step. Not every proxy server answers with an instant 400. On a server that waits for a line ending, the symptom is a timeout.

HTTP client, SOCKS5 port

An HTTP client connecting to a SOCKS5 port sends a request line. The SOCKS5 server reads the first byte as the version number. For GET that byte is 0x47, for CONNECT it is 0x43. Neither is 0x05. What happens next depends entirely on the server software. The server sends no reply; it only chooses what to do with the connection.

We tried three behaviours on separate test servers:

Server behaviourcurl 8.22.0Requests 2.34.2
Closes at once without reading(56) Recv failure: Connection was resetProxyError, ConnectionResetError
Reads everything, then closes(52) Empty reply from serverProxyError, RemoteDisconnected
Does not close, waits(28) Operation timed outReadTimeout

With an HTTPS target the messages changed slightly. On the second row curl printed (56) Proxy CONNECT aborted, on the third (28) Connection timed out. Requests returned ConnectionError: Connection aborted on the first two rows. With the https:// scheme against the SOCKS5 port, curl started a TLS handshake and stopped with (35) Recv failure: Connection was reset.

This direction is more misleading. ProxyError: Unable to connect to proxy reads as if the proxy were down. ReadTimeout looks like a slow network. The port is open and the connection is established; the problem is only the language spoken. Connection refused is a different problem: nothing is listening on that port.

Correct scheme and port

The fix is to write the scheme that matches the protocol the port listens on. Proxynet supports HTTP and SOCKS5. Match the protocol to the port in your dashboard and build the URL from that pair. The examples in this post use port 8000. For your own connection, use the port shown in your dashboard.

bash
# If the port listens for HTTP
curl -x "http://user:pass@pr.proxynet.io:8000" \
  https://httpbin.org/ip

# If the port listens for SOCKS5 (the proxy resolves DNS)
curl -x "socks5h://user:pass@pr.proxynet.io:8000" \
  https://httpbin.org/ip

In curl you can also give the scheme outside the URL. The --socks5-hostname flag does the same as socks5h://. For the other options, go to cURL with Proxy.

In Python, Requests needs an extra package for SOCKS: pip install "requests[socks]". Without it, Requests raises Missing dependencies for SOCKS support. That is not a mismatch symptom. If you want the target resolved on the proxy side, write socks5h://. For jobs that need UDP, see the SOCKS5 Proxy page.

python
import requests

proxy = "socks5h://user:pass@pr.proxynet.io:8000"
r = requests.get(
    "https://httpbin.org/ip",
    proxies={"http": proxy, "https": proxy},
    timeout=10,
)
print(r.status_code, r.text)

If the protocol is a matter of choice, we compared the two in SOCKS vs. HTTP Proxy.

Debugging

The fastest diagnosis is to try the same URL with both schemes. Whichever scheme returns 200 is the protocol the port listens on. Always set a time limit in the command. Otherwise the command hangs for a long time on a waiting server.

bash
for s in http socks5h; do
  curl -sS -m 10 -o /dev/null -w "$s %{http_code}\n" \
    -x "$s://user:pass@pr.proxynet.io:8000" https://httpbin.org/ip
done

In Windows PowerShell the same test looks like this. The $($s) form is required, because $s: means something else in PowerShell.

powershell
foreach ($s in "http", "socks5h") {
  curl.exe -sS -m 10 -o NUL -w "$s %{http_code}`n" `
    -x "$($s)://user:pass@pr.proxynet.io:8000" https://httpbin.org/ip
}

In our test the HTTP port printed http 200 and socks5h 000. On the SOCKS5 port the result was reversed. 000 means curl got no HTTP response at all. In Python you can also try both schemes in a loop, one after the other.

MessageLikely causeWhat to do
(97) Received invalid version in initial SOCKS5 responseSOCKS5 scheme, HTTP portWrite http://
SOCKS5 proxy server sent invalid dataSame cause, PythonWrite http://
(56) Recv failure: Connection was resetHTTP scheme, SOCKS5 portWrite socks5h://
(52) Empty reply from serverSame cause, different serverWrite socks5h://
(28) or ReadTimeout, port openServer waiting, scheme may be wrongTry both schemes
(35) TLS errorhttps:// scheme, port without TLShttp:// or socks5h://

If both schemes fail, the problem is not the scheme. Check the port first, then the credentials and network access.

How we tested

We ran the tests on December 1, 2026, on Windows 11. We used curl 8.22.0 (Windows), Python 3.13.17, Requests 2.34.2, PySocks 1.7.1 and Node.js 24.22.2. On 127.0.0.1 we set up an HTTP proxy with Node's built-in HTTP server. In Python we wrote a SOCKS5 server that follows RFC 1928 and RFC 1929. We ran that server in three modes: close at once, read then close, and wait. As targets we used a local HTTP server and https://example.com. Each scenario ran in a fresh process with a 10-15 second time limit. The connection reset messages may be specific to Windows. On another operating system the same case can show up with a different error code. In the examples we replaced the local address with pr.proxynet.io:8000.

The bottom line

Pick the scheme from the protocol the port listens on. To diagnose, try the same URL once with http:// and once with socks5h://, each with a time limit. Above all, when you see curl 97 or invalid data, check the scheme before you change the password. Once your URL is ready, you can send the first request with Residential Proxy.

Sources

Frequently asked questions

What does Received invalid version in initial SOCKS5 response mean?

It means the SOCKS5 client did not get the reply it expected. The client expects the first reply byte to be 0x05. If the port belongs to an HTTP proxy, the reply starts with HTTP/1.1 400 and the first byte is the letter H. curl reports this with code 97. The fix is usually to change the scheme to http://. Neither the password nor the network connection causes this message.

Can you connect to an HTTP proxy with socks5?

No. An HTTP proxy only understands HTTP requests and does not recognise the SOCKS5 greeting. In our test the proxy returned 400 Bad Request in this case, and the client dropped the connection. The same provider can offer both protocols, but each port listens for only one. Check in your dashboard which port listens for SOCKS5 and write the scheme to match.

Why do I get a timeout when I use http:// on a SOCKS5 port?

The server may be holding the request it does not understand. A SOCKS5 server treats the first byte of the GET or CONNECT line as the version number. Some servers close the connection at once, others wait silently. On a waiting server, curl returns (28) and Requests returns ReadTimeout. If the same URL goes through at once with socks5h://, this is the cause.

How do I tell whether a proxy port is HTTP or SOCKS5?

Try the same URL with both schemes. Whichever of curl -m 10 -x "http://…" and curl -m 10 -x "socks5h://…" returns 200 is the protocol the port listens on. Always set the time limit, because the wrong scheme sometimes just ends in waiting. The most reliable source is still the provider's dashboard. The dashboard lists the protocol and port together.

Does ProxyError: Unable to connect to proxy always mean the proxy is down?

No. In our test this error also appeared when connecting to an open SOCKS5 port with http://. The server accepted the connection, then closed it when it did not recognise the first byte. Requests reported this as a failure to connect to the proxy. Try changing the scheme first. If both schemes give the same error, check the port, the address or network access.

Does socks5 versus socks5h make a difference for this error?

No. Both send the same SOCKS5 greeting; the only difference is DNS resolution. In our test curl returned the same error 97 with both schemes against the HTTP port. Once the mismatch is fixed, the choice matters. With socks5h:// the proxy resolves the target name, and the query does not leave your network. For results that vary by location, this option is the better fit.

Ask ChatGPTAsk Claude