What is a SOCKS5 proxy
SOCKS5 is a proxy protocol that carries any connection without inspecting its contents.
Updated · Prokso editorial team
- SOCKS5 relays TCP connections of any program without inspecting their contents; the protocol is defined in RFC 1928 and username login in RFC 1929.
- In Prokso, SOCKS5 runs on port 824 with a new IP per request and on ports 10000-20000 with a sticky IP.
- Write socks5h:// so that the proxy, not your ISP, resolves the site name.
- SOCKS5 does not encrypt traffic, and UDP does not pass through Prokso proxies: games and calls will not work.
SOCKS5 is the fifth version of the SOCKS protocol, which a program uses to send its connections through a proxy server. Unlike an HTTP proxy, SOCKS5 does not look into what is being sent: it relays bytes between the program and the server unchanged. That is why it suits not only websites but also messengers, database clients and other applications that do not work through a browser.
The protocol is defined in RFC 1928, and username and password login in a separate RFC 1929. SOCKS5 can pass the site name to the proxy so that the proxy, not your device, resolves the address. Its reply codes are sparse: instead of a detailed status, as in HTTP, the program gets a single byte such as "general failure" or "connection refused". That is why it is often easier to look for the cause of a problem over HTTP.
In Prokso, SOCKS5 runs on port 824 with a new IP per request and on ports 10000-20000 with a sticky IP. Countries and prices are on the SOCKS5 proxies page. Below: how the protocol works, how it differs from SOCKS4 and HTTP, how to use it in curl, Python and Node.js, and what to do if the connection is not established.
SOCKS5, SOCKS4 and HTTP proxies: what differs
| SOCKS4 | SOCKS5 | HTTP(S) proxy | |
|---|---|---|---|
| What it carries | TCP only | TCP; UDP is described in the standard, but a service may not support it | HTTP requests and CONNECT tunnels for HTTPS |
| Username and password login | no, only a user ID field | yes, per RFC 1929 | yes, the Proxy-Authorization header |
| Site name instead of IP | no, added in the SOCKS4a extension | yes | yes |
| IPv6 | no | yes | yes |
| Error codes | a few generic ones | nine reply codes | the full set of HTTP statuses, including 407 |
| In Prokso | not supported | port 824 and 10000-20000 | port 823 and 10000-20000 |
The previous version, SOCKS4, is rare today: without passwords and IPv6 it fits few tasks. Speed hardly depends on the protocol: it is set by the exit address, the distance to the site and the site itself. An HTTP proxy is more convenient for browsers and scripts that work only with the web, because it gives clear error codes. SOCKS5 is needed where a program does not speak HTTP or its settings only have a SOCKS field.
How a SOCKS5 connection is set up
First the program and the proxy agree on the login method: no password, or a username and password. Then the program sends a command meaning "connect me to this host and port", and the proxy opens that connection from the exit address. After that the bytes simply flow both ways unchanged.
The site name can be passed in two ways: as a ready IP address that the program looked up itself, or as a domain name that the proxy resolves. This decides who sees your DNS queries.
What RFC 1928 and RFC 1929 say
The RFC 1928 specification came out in 1996. First the client lists the login methods it supports, and the server picks one: no authentication, GSSAPI, or username and password. Then the client sends a request with one of three commands: CONNECT to connect to a host, BIND to wait for an incoming connection, UDP ASSOCIATE to relay UDP. The destination can be given as IPv4, IPv6 or a domain name.
The server replies with a code: 0 - success, 1 - general server failure, 2 - connection not allowed by the rules, 3 - network unreachable, 4 - host unreachable, 5 - connection refused, 6 - TTL expired, 7 - command not supported, 8 - address type not supported. These are exactly the codes programs show as "general failure" or "connection refused".
RFC 1929 describes username and password login: each up to 255 bytes, and both are sent in plain text. The Prokso gateway accepts the plan's username and password, or lets in addresses from the IP whitelist without them.
socks5:// or socks5h://: who resolves the site address
In curl, Python libraries and a number of other tools the socks5:// scheme means the program resolves the site name itself, through your ISP. The socks5h:// scheme hands the name to the proxy, and the address is resolved on its side. In the first case DNS queries go around the proxy, which is a DNS leak.
A sign of the problem: the site opens, but test services show the DNS server of your ISP rather than one in the proxy's country. The Prokso string in that case looks like socks5h://LOGIN:PASSWORD@gw.prokso.com:824. If a program does not know the scheme with the letter h, look in its settings for an option to resolve names through the proxy.
How to connect over SOCKS5: curl, Python and Node.js
The examples use port 824, that is, a new IP per request. The page https://prokso.com/ip returns the IP, country and network the request came from, so you can see right away that the response goes through the proxy. LOGIN and PASSWORD are your plan's credentials from the dashboard.
curl -x socks5h://LOGIN:PASSWORD@gw.prokso.com:824 https://prokso.com/ip
curl --socks5-hostname gw.prokso.com:824 --proxy-user LOGIN:PASSWORD https://prokso.com/ip
Both lines are equivalent: the socks5h:// scheme and the --socks5-hostname option pass the site name to the proxy. The --socks5 option resolves the name on your device. More examples are in the curl guide.
Python requests works with SOCKS only with the PySocks package, which is installed together with the requests[socks] extra:
pip install "requests[socks]"
import requests
proxy = "socks5h://LOGIN:PASSWORD@gw.prokso.com:824"
r = requests.get("https://prokso.com/ip", proxies={"http": proxy, "https": proxy}, timeout=30)
print(r.json())
Step-by-step setup is in the Python requests guide. In Node.js the built-in fetch does not accept an agent option, so the socks-proxy-agent package is easiest to use with the standard https module:
import https from "node:https";
import { SocksProxyAgent } from "socks-proxy-agent";
const agent = new SocksProxyAgent("socks5h://LOGIN:PASSWORD@gw.prokso.com:824");
https.get("https://prokso.com/ip", { agent }, (res) => res.pipe(process.stdout));
Other options for Node.js are in the Node.js guide. In all three examples the response should show the proxy's IP and country, not yours.
SOCKS5 does not encrypt traffic
A common mistake is to treat SOCKS5 as a secure channel. The protocol only relays bytes, and under RFC 1929 the username and password travel in plain text. Your data is protected not by the proxy but by the encryption of the connection itself: HTTPS pages stay encrypted from your program to the site, and the gateway only sees which domain and port you connect to and the traffic volume.
So open sites over HTTPS through the proxy and do not enter passwords on unencrypted pages. If you do not want the plan's username to travel over the network, connect without it, using the IP whitelist. How a proxy differs from a tunnel that encrypts everything is explained in the article "Proxy vs VPN", including its section on SOCKS5 and VPN.
What SOCKS5 in Prokso does not carry
The SOCKS5 protocol also describes forwarding UDP, but in Prokso UDP is not supported on any port. So calls in messengers and online games will not work through the proxy, even if the program lets you enter SOCKS5.
For a sticky IP, SOCKS5 works the same way as HTTP: ports 10000-20000 accept both protocols. Port 824 gives a new IP per request, so for long sessions in apps take a port from that range.
Where SOCKS5 is needed and where HTTP is enough
- Telegram. The app accepts SOCKS5 with a username and password; step by step in the Telegram guide. Messages and files go through the proxy, calls do not, because they need UDP.
- Programs without proxy settings. Proxifier intercepts the connections of chosen programs and sends them through SOCKS5 or HTTP, see the Proxifier guide.
- Browsers and antidetect browsers. They work with both protocols. HTTP is more convenient here thanks to clear error codes, while SOCKS5 is chosen out of habit or when a tool requires it.
- Scripts and scrapers. Both protocols fit; with SOCKS5, do not forget
socks5h. - Online games and calls. They do not work through Prokso proxies over any protocol. Why - in the article "Proxies for gaming".
When a SOCKS5 connection is not established
| What you see | What it usually means | Details |
|---|---|---|
| general SOCKS server failure | the gateway accepted the request but could not connect to the site | SOCKS5 general failure |
| connection refused | the site refused, or the connection to the proxy itself failed: port, host, login method | SOCKS5 connection refused |
| ERR_SOCKS_CONNECTION_FAILED in Chrome | the handshake with the proxy failed | ERR_SOCKS_CONNECTION_FAILED |
| Missing dependencies for SOCKS support | PySocks is not installed for requests | Missing dependencies |
| httpx or aiohttp errors with SOCKS | an extra package is missing or the proxy is set the old way | httpx and aiohttp |
The most common cause is a mixed-up protocol: a SOCKS5 string in an HTTP field or port 823 in a SOCKS field. Match the port to the protocol and paste the string into the proxy checker: it shows whether the port answers and whether the username and password are accepted. Other cases are in the proxy errors section.
Further reading
FAQ
Is SOCKS5 faster than HTTP?
There is no noticeable difference in speed: it depends on the exit address and the site, not on the protocol. SOCKS5 does not parse requests, but this has almost no effect on page loading.
Where is SOCKS5 needed most often?
In messengers such as Telegram, in applications that work with more than web pages, and where the settings only have a SOCKS field. Both protocols fit browsers and scripts.
Does SOCKS5 encrypt my data?
No. SOCKS5 relays bytes unchanged and sends the username and password in plain text. Your data is protected by the site's HTTPS: such pages stay encrypted from your program to the site.
What is the difference between socks5:// and socks5h://?
With socks5:// your device resolves the site name through its ISP, and DNS queries bypass the proxy. With socks5h:// the proxy receives the name and the gateway resolves the address. For Prokso write socks5h://LOGIN:PASSWORD@gw.prokso.com:824.
Do games and calls work through Prokso SOCKS5?
No. They need UDP, while Prokso carries only TCP on all ports, and SOCKS5 does not change that. Websites, Telegram messages, scripts and APIs work.
How do I check that SOCKS5 works?
Run curl -x socks5h://LOGIN:PASSWORD@gw.prokso.com:824 https://prokso.com/ip: the response should show the proxy's IP and country, not yours. In a browser the My IP page shows the same, and you can paste the whole string into the proxy checker.
Related terms
Residential $1.59, mobile $2.50, datacenter $0.65 per GB
Sign up in a minute, get access right after payment.