All locations active · 99.99% uptime
SOCKS5

How Does a SOCKS5 Proxy Work?

what a SOCKS5 proxy is article we introduced the concept. Here we look inside the protocol: which bytes travel between the client and the server, how the address is specified, and why this design produces a more general-purpose tool than an HTTP proxy.

SOCKS5 is a remarkably simple protocol defined in RFC 1928. Its simplicity is the source of its power: it never interprets application-layer data, it only carries TCP (and optionally UDP) traffic.

The Three-Stage Handshake

FIGUREThe stages of a SOCKS5 connection
HANDSHAKE01Greeting(greeting)1 round tripThe client lists theauthentication methodsit supports02Methodselectionsame round tripThe server choosesone orrejects03Authentication1 round tripThe selected methodis applied (if required)04CONNECT request1 round tripThe target address and portare announced05Data transferindefiniteThe protocol is now a transparent pipeconnection lifetime →

If no authentication is required, three round trips become two. It needs slightly more round trips than the HTTP proxy's CONNECT method, but the bytes are far smaller.

Stage 1 — The Greeting

In its first packet the client announces the protocol version and the authentication methods it supports:

FIGUREThe client greeting packet
REQUESTVER0x05SOCKS version: 5NMETHODS0x02How many methods are offeredMETHODS[0]0x00No authentication requiredMETHODS[1]0x02Username / password

The server announces its choice with a single-byte reply: 0x00 (no authentication required), 0x02 (username/password) or 0xFF (no acceptable method).

Debugging tip

The server sends 0xFF and closes the connection, it means your client is not offering the authentication method the server expects. This is the most common cause of the "the connection closed silently" complaint.

Stage 2 — Authentication

If method 0x02 is selected, the sub-negotiation defined in RFC 1929 takes place: a version byte, the username length and the username, the password length and the password. The server returns a single-byte success/failure.

For a detailed comparison and practical configuration, see our SOCKS5 authentication article .

Stage 3 — The CONNECT Request

Once authentication has passed, the client announces the target. This is where SOCKS5's most important design decision comes into play: the address can be given in three different formats.

FIGUREThe structure of the CONNECT request
REQUESTVER0x05VersionCMD0x0101=CONNECT, 02=BIND,03=UDPRSV0x00ReservedATYP0x0301=IPv4, 03=domain name,04=IPv6ADDRornek.comTarget addressPORT0x01BB443

ATYP=0x03 means a domain name; in that case DNS resolution is performed by the proxy. This single byte is the key to preventing DNS leaks.

Why Is It More General Than an HTTP Proxy?

FIGUREThe layers the two protocols operate at
LAYER7ApplicationHTTP / HTTPS / SMTP / FTPAn HTTP proxy only understands HTTP5SessionSOCKS5It does not look at content; it carries everything4TransportTCP / UDPSOCKS5 supports both3NetworkIPv4 / IPv6Addressing

An HTTP proxy reads and interprets the request; SOCKS5 only carries it. That is why e-mail, gaming, file transfer and browser traffic can all pass over SOCKS5 at the same time.

FeatureHTTP proxySOCKS5
The layer it operates atApplication (7)Session (5)
Protocol supportHTTP(S) onlyAny TCP, optionally UDP
Content interpretationYesNo
Header injectionCanCannot
CachingPossibleNot possible
DNS resolutionOn the proxy sideSelectable (ATYP)
Handshake round trips1 (CONNECT)2–3

For a detailed comparison, see the difference between an HTTP proxy and SOCKS5 article.

Does SOCKS5 Encrypt?

No. This is the most common misunderstanding. SOCKS5 is a transport protocol; it offers no encryption. The security of your traffic depends on the encryption of the content being carried:

  • If it goes over HTTPS: TLS protects it end to end; the proxy cannot see the content.
  • If it is plain HTTP: The proxy operator can read the content.
  • Credentials: The SOCKS5 username/password is sent in plain text.
Security note

SOCKS5 credentials are transmitted unencrypted. If you use a SOCKS5 proxy on an untrusted network, your credentials can be read by an observer in between. In that scenario it is safer to use SOCKS5 over an SSH tunnel — we explain the method a separate article in detail.

Practical Use

FIGUREBasic operations with SOCKS5
Terminal01# Resolve DNS on the proxy side (recommended)02curl --socks5-hostname kullanici:sifre@proxy.example.com:1080 https://example.com0304# Resolve DNS locally (leak risk)05curl --socks5 proxy.example.com:1080 https://example.com0607# Via an environment variable (many tools read this)08export ALL_PROXY="socks5h://kullanici:sifre@proxy.example.com:1080"0910# Python requests (for socks support: pip install requests[socks])11proxies = {"http": "socks5h://kullanici:sifre@proxy.example.com:1080",12 "https": "socks5h://kullanici:sifre@proxy.example.com:1080"}1314# Test: exit IP15curl --socks5-hostname proxy.example.com:1080 -s https://ornek-ip.example/text

socks5h scheme's h means "hostname" and makes DNS resolution happen on the proxy side. Always prefer it to prevent leaks.

When Should You Choose SOCKS5?

Choose SOCKS5

  • If you will carry non-HTTP protocols (e-mail, FTP, gaming).
  • If you want DNS resolution done on the proxy side.
  • If you need UDP traffic.
  • If you do not want the proxy touching your headers.
  • If the application only supports SOCKS.

An HTTP proxy is enough

  • If you will only carry web traffic.
  • If you want caching.
  • If your tool only supports HTTP proxies.
  • If the lowest possible number of handshake round trips matters.
  • If you need corporate filtering rules.

Summary

SOCKS5 is a simple session-layer protocol that carries TCP and UDP traffic without ever looking at application data. Thanks to its three-stage handshake, its support for three different address types and the domain name option, it makes preventing DNS leaks possible. It provides no encryption; security depends on the encryption of the content being carried. If you need to carry non-web traffic, it is the right tool. For product details, see our SOCKS5 proxy page, and for testing, our proxy checker tool .

Frequently Asked Questions

01Does SOCKS5 encrypt my traffic?

No. SOCKS5 is a transport protocol and offers no encryption. Security comes from the encryption of the content being carried; if you use HTTPS, the content is protected end to end.

02What is the difference between socks5 and socks5h?

socks5h asks for DNS resolution to be performed on the proxy side, while socks5 resolves locally. Always prefer socks5h to prevent leaks.

03My SOCKS5 connection closes silently — why?

Most likely your client is not offering the authentication method the server expects. The server returns 0xFF and closes the connection. Make sure your client supports the username/password method.

04Is SOCKS5 slower than an HTTP proxy?

The handshake costs one extra round trip, but the bytes carried are very small. In practice the difference is a few milliseconds, and once data transfer begins there is no speed difference between the two protocols.

05Does every application support SOCKS5?

No. Browsers, curl and most modern libraries do; however, some applications only understand HTTP proxies. In that case you need to put a protocol converter in between.

Related Articles and Pages

NEXT STEP

Strengthen your proxy setup today.

Get started in minutes with a paid plan, or try our free proxy list first.

FREEPROXY.TR

Looking for a free proxy? You're in the right place

A complete proxy platform where you can browse up-to-date free proxy addresses, compare HTTP and SOCKS proxy types, and check your proxy connections with free tools.