SOCKS5 connection refused is the error that reports a TCP connection was turned away by the other side. The refusal can come from two places. Either the proxy port does not accept your connection, or the proxy connects but the target server turns the proxy away and the SOCKS reply carries code 0x05. The two cases need different fixes, yet the tools report them in similar words. This post covers the two refusal points, the RFC 1928 reply codes, authentication rejections and the order of checks.
Two separate refusal points
A SOCKS5 connection is made of two TCP connections. The first runs from your machine to the proxy. The proxy opens the second one to the target server on your behalf. Whichever of the two connections fails is where the problem lives.
| Refusal point | What happens | Typical cause |
|---|---|---|
| Client → proxy | The TCP handshake is cut with an RST | Wrong port or host, service down, firewall |
| Proxy → target | The proxy returns reply 0x05 | Target port closed, target service not running |
| During the handshake | The proxy returns 0xFF or an auth error | Authentication method or password mismatch |
In the first row the SOCKS exchange never starts. In the second and third rows the proxy answers you and sends a code. That difference drives the whole diagnosis.
Refusal at the proxy port
A refusal at the proxy port means the operating system answers your connection request with an RST packet. An RST says "nobody is listening on this port." The tool has not reached the SOCKS handshake yet.
Four causes produce this picture:
- Wrong port. The address has a number other than
8000, or no port at all. - Wrong host. The hostname resolves to a different machine, and that port is closed there.
- Service down. A SOCKS server you run yourself has crashed or is restarting.
- Firewall. If the firewall rejects the packet (REJECT), you get the same error. If it silently drops it (DROP), you see a timeout instead of a refusal.
The gap between a refusal and a timeout is a useful clue. A refusal arrives instantly, because the other side answers. A timeout means no answer came at all. Our post on the err_connection_refused error covers the browser version of this error. Here we only look at the SOCKS5 side.
The trap is in curl's message. In our test, curl 8.22.0 printed Failed to connect to <target> over proxy <proxy> for a closed proxy port. The message names the target address, not the proxy port. So the error reads as if it belonged to the target. The verbose output from -v shows the real port in the line connect to 127.0.0.1 port 18099 ... failed: Connection refused.
SOCKS5 reply codes
A SOCKS5 server answers every connection request with a reply byte. Section 6 of RFC 1928 defines this field as REP. 0x00 is success, and 0x01 to 0x08 are error codes.
| Code | Meaning in the RFC | Common cause |
|---|---|---|
0x01 | General server failure | An unexpected problem inside the proxy |
0x02 | Not allowed by ruleset | Target port or address blocked by a server rule |
0x03 | Network unreachable | The proxy has no route to the target network |
0x04 | Host unreachable | The target does not answer, or the name did not resolve |
0x05 | Connection refused | Target port closed, target service not running |
0x06 | TTL expired | The connection to the target was not set up in time |
0x07 | Command not supported | The server does not implement BIND or UDP |
0x08 | Address type not supported | The server does not accept IPv6 or the domain-name format |
The SOCKS equivalent of connection refused is 0x05. The proxy tried to reach the target and got an RST. So the proxy is healthy and your credentials were accepted. The problem is the target itself.
An overlooked cause of 0x05 is writing localhost or a private network address as the target. The proxy tries to reach that address from its own machine, not from yours. Another cause is a wrong target port: the address has a port the service does not listen on, instead of 443.
The code mapping can vary between servers. The RFC does not spell out which internal error maps to which code. For a name that does not resolve, one server may pick 0x04 and another 0x01. Read the code as a pointer, not as a final diagnosis.
0x07 is a support issue, not a refusal. If your application needs UDP or BIND, the server has to implement that command. Proxynet SOCKS5 Proxy also support the UDP ASSOCIATE command.
Authentication rejections
The SOCKS5 handshake starts with a method negotiation. The client lists the methods it supports: 0x00 for no authentication, 0x02 for username and password. The server picks one. If none fits, it returns 0xFF and closes the connection.
The typical cause of 0xFF is a proxy address with no credentials. The server asks for a password, while the client only offers 0x00. In our test, curl reported this as No authentication method was acceptable.
With a wrong password, the method negotiation passes and the error comes one step later. Under RFC 1929, the server returns a non-zero status byte and closes the connection. curl printed User was rejected by the SOCKS5 server (1 1). If the password contains @ or #, check the percent-encoding first: pass@123 must be pass%40123 in the address.
With an IP whitelist, things change. Servers turn away an address that is not on the list in different ways: they close the connection right away, return 0xFF, or reject it with 0x02. Against a server that closes the connection right away, curl printed (97) Recv failure: Connection was reset in our test. If your home internet IP has changed, the old address on the list no longer works. Our post on proxy authentication explains the difference between the two methods.
Error messages by tool
The same refusal shows up as a different sentence in each tool. The messages below were recorded from our local test server on 1 December 2026.
| Case | curl 8.22.0 | requests + PySocks |
|---|---|---|
| Proxy port closed | (7) Failed to connect to … over proxy … | [WinError 10061] |
| Target refused | (97) cannot complete SOCKS5 connection to … (5) | 0x05: Connection refused |
| No method | (97) No authentication method was acceptable. | All offered SOCKS5 authentication methods were rejected |
| Wrong password | (97) User was rejected by the SOCKS5 server (1 1). | SOCKS5 authentication failed |
| Connection closed at once | (97) Recv failure: Connection was reset | [WinError 10054] |
In curl, the exit code is the first clue. 7 means the connection could not be made. 97 means the proxy handshake failed. The number at the end of a cannot complete SOCKS5 connection message is the RFC 1928 reply code.
On the requests side, every case arrives as requests.exceptions.ConnectionError. The difference sits in the inner message in brackets. WinError 10061 is the Windows refusal code; on Linux the equivalent is [Errno 111] Connection refused. Watch out: the requests message also names the target's host and port, not the proxy's.
In HTTPX, SOCKS support is an extra package. If you pass a socks5:// address without installing pip install httpx[socks], the client raises ImportError before it even connects. That package was not installed in our test, so we did not record HTTPX's refusal messages.
To separate the two cases in your own code, use PySocks' exception classes:
import socks
def try_socks5(host, port, target, user=None, pw=None):
s = socks.socksocket()
s.set_proxy(socks.SOCKS5, host, port, rdns=True,
username=user, password=pw)
s.settimeout(10)
try:
s.connect(target)
return "ok"
except socks.ProxyConnectionError as e:
# TCP never reached the proxy: host, port, firewall
return f"proxy port unreachable: {e}"
except socks.GeneralProxyError as e:
# The proxy answered: reply code, 0xFF or password error
return f"proxy answered but refused: {e}"
finally:
s.close()
print(try_socks5("pr.proxynet.io", 8000, ("example.com", 80), "user", "pass"))rdns=True makes the proxy resolve the target name. It is the equivalent of the socks5h:// scheme in curl. In our test, this function sorted the closed port, 0x05, 0xFF and the wrong password into the right group.
Troubleshooting
Work from the outside in: port first, then the handshake, the target last. Each step narrows the question for the next one.
1. Is the proxy port open? On Windows, with PowerShell:
Test-NetConnection pr.proxynet.io -Port 8000If you see TcpTestSucceeded : False, the problem is the connection, not SOCKS. On Linux and macOS, nc -vz pr.proxynet.io 8000 asks the same question. Compare the hostname and port character by character with the details in your dashboard.
2. Where does the handshake break? Run curl in verbose mode:
curl -v -x socks5h://user:pass@pr.proxynet.io:8000 \
https://example.com/If the exit code is 7, go back to step one. If it is 97, read the rest of the message. An auth error points to the password or the whitelist, and (5) points to the target.
3. Is the target itself open? Try the same address without the proxy:
curl -v https://example.com/If the target refuses you as well, the problem is not the proxy. The target port or service is closed. If it opens for you but not for the proxy, the target may not accept connections from the proxy's network. In that case, check the address and port again, and contact the site owner if needed.
Do not skip steps. Changing the password does not open a closed port. Changing the proxy does not open a closed target port either.
How we tested
We ran the tests on 1 December 2026 on Windows 11. We wrote a small Python SOCKS5 server that implements RFC 1928 and RFC 1929. Each scenario ran on its own port: real forwarding, a server that asks for a password, servers that force each code from 0x01 to 0x08, and a server that accepts the connection and closes it at once. As targets we used a local HTTP server and a port with no listener.
| Scenario | Result |
|---|---|
| Closed proxy port | ✗ curl (7), requests WinError 10061 |
| Closed target port | ✗ the server really returned 0x05, curl (97) … (5) |
| No credentials, password server | ✗ 0xFF, both tools reported the method rejection |
| Wrong password | ✗ RFC 1929 status 0x01, both tools reported the auth error |
| Correct password | ✓ HTTP 200 |
Tool versions: curl 8.22.0, Python 3.13, requests 2.34.2, PySocks 1.7.1, HTTPX 0.28.1. We ran the curl, PowerShell and Python examples in this post with the address swapped for the local server. We did not try the nc command on Windows.
The bottom line
Check the curl exit code first: 7 points to the proxy port, 97 to the handshake, (5) to the target. Above all, compare the host and port with the values in your dashboard, because a single mistyped digit is enough for (7). Proxynet Residential Proxy work over both HTTP and SOCKS5.
Sources
- RFC 1928, SOCKS Protocol Version 5, sections 3 and 6: rfc-editor.org
- RFC 1929, Username/Password Authentication for SOCKS V5: rfc-editor.org
- libcurl error codes, CURLE_COULDNT_CONNECT and CURLE_PROXY: curl.se
- HTTPX, Proxies, SOCKS section: python-httpx.org
Frequently asked questions
Does SOCKS5 connection refused come from the proxy or the target?
It can come from either. If the curl exit code is 7, the proxy port refused the connection and the SOCKS exchange never started. If the exit code is 97 and the message ends with (5), the proxy is working. In that case the target server refused the proxy's connection. In Python, 0x05 points to the target, while WinError 10061 or Errno 111 points to the proxy port.
What does reply code 0x05 mean?
In RFC 1928, 0x05 means "connection refused." The proxy tried to connect to the target address and got an RST. Your credentials were accepted and the proxy is working. Check that the target port is open, that the address is not localhost or a private network address, and that the service is running.
How do I fix "No authentication method was acceptable"?
Add a username and password to the address. The message says the server returned 0xFF: none of the methods the client offered suited the server. The most common cause is connecting without credentials to a server that requires a password. Write the address as socks5h://user:pass@pr.proxynet.io:8000 and percent-encode any special characters in the password.
Why is the connection refused when I use an IP whitelist?
Because the IP you connect from is not on the list. On home and mobile internet, your outgoing IP can change over time. The list still holds the old address, so the server turns the new one away. Depending on the server, the connection closes at once, or you get 0xFF or 0x02. Look up your current IP on an IP echo page and add it to the list.
What is the difference between connection refused and a timeout?
A refusal arrives instantly, a timeout after a wait. A refusal means the other side answered with an RST: the machine was reached, but the port is closed. With a timeout, no answer comes at all. The cause is usually a firewall that silently drops packets, or a wrong IP address.
Why does the Python requests SOCKS5 error show the target address?
requests always builds the message around the target you sent the request to. The host and port in the SOCKSHTTPConnectionPool(host=...) part belong to the target, not the proxy. The real cause is in the inner message in brackets. 0x05: Connection refused points to the target, WinError 10061 to the proxy port. To tell them apart, catch PySocks' ProxyConnectionError class.




