What Is a SOCKS5 Proxy? A Complete Technical Guide

What Is a SOCKS5 Proxy? A Complete Technical Guide

A SOCKS5 proxy is a versatile internet protocol that routes network traffic between a client and a server through a proxy server. Unlike HTTP proxies that only handle web traffic, SOCKS5 operates at a lower level of the networking stack (Layer 5 — the session layer), enabling it to handle virtually any type of internet traffic including web browsing, email, file transfers, torrenting, and gaming.

SOCKS5 is the latest version of the SOCKS (Socket Secure) protocol, adding critical features like authentication and UDP support that make it the preferred choice for users who need flexibility and security.

Table of Contents

How SOCKS5 Proxies Work

The SOCKS5 protocol works by establishing a TCP connection to the proxy server and then negotiating the connection parameters before forwarding traffic. Here’s the detailed process:

Connection Handshake

  1. Client greeting — Your application connects to the SOCKS5 proxy server and sends a greeting that includes the authentication methods it supports.
  2. Server response — The proxy server selects an authentication method (or none if anonymous access is allowed).
  3. Authentication — If required, the client provides username/password credentials.
  4. Connection request — The client tells the proxy where it wants to connect (destination IP/domain and port).
  5. Proxy connection — The SOCKS5 server establishes the connection to the target and begins relaying data in both directions.

Technical Architecture

Client Application

↓ (SOCKS5 protocol)

SOCKS5 Proxy Server

↓ (TCP/UDP connection)

Target Server (any protocol)

The key difference from HTTP proxies is that SOCKS5 doesn’t interpret or modify the data passing through it. It simply establishes a tunnel and relays raw packets, making it protocol-agnostic.

The SOCKS5 Handshake in Detail

# Step 1: Client sends version and auth methods

Client → Proxy: [0x05][0x02][0x00][0x02]

VER NMETH NO_AUTH USER/PASS

Step 2: Server selects auth method

Proxy → Client: [0x05][0x02]

VER USER/PASS method selected

Step 3: Client authenticates

Client → Proxy: [0x01][len][username][len][password]

Step 4: Server confirms

Proxy → Client: [0x01][0x00]

VER SUCCESS

Step 5: Client requests connection

Client → Proxy: [0x05][0x01][0x00][0x03][len][domain][port]

VER CONNECT RSV DOMAIN

Step 6: Proxy confirms connection

Proxy → Client: [0x05][0x00][0x00][0x01][bind_addr][bind_port]

VER SUCCESS

SOCKS5 vs. SOCKS4: What Changed

SOCKS5 was defined in RFC 1928 and introduced significant improvements over SOCKS4:

FeatureSOCKS4SOCKS5
AuthenticationNoneUsername/password, GSS-API
UDP SupportNoYes
IPv6 SupportNoYes
DNS ResolutionClient-side onlyServer-side (remote DNS)
Domain NamesNot supported directlyFull support
SecurityBasicMultiple auth methods

The addition of UDP support is particularly significant because it enables use cases like DNS queries, VoIP, video streaming, and online gaming that rely on UDP rather than TCP.

SOCKS5 vs. HTTP Proxies

For a detailed comparison, see our guide on SOCKS5 vs. HTTP proxies. Here’s a summary:

AspectSOCKS5 ProxyHTTP Proxy
Protocol SupportAny (TCP + UDP)HTTP/HTTPS only
OSI LayerLayer 5 (Session)Layer 7 (Application)
Data InspectionNo (transparent tunnel)Yes (can read/modify headers)
SpeedGenerally fasterCan cache for speed
Use CasesAny applicationWeb browsing/scraping
Content FilteringNot possibleCan filter content
HTTPS SupportYes (tunneling)Yes (CONNECT method)

When to Choose SOCKS5 Over HTTP

Choose SOCKS5 when you need:

  • Support for non-HTTP protocols (FTP, SMTP, P2P)
  • UDP traffic handling (gaming, streaming, DNS)
  • No data modification by the proxy
  • A protocol-agnostic solution

Choose HTTP when you need:

  • Web-specific optimization (caching, header modification)
  • Content filtering capabilities
  • Simpler setup for web scraping
  • Better integration with web automation tools

Key Features of SOCKS5 Proxies

1. Protocol Independence

SOCKS5 doesn’t care what protocol your application uses. It works with:

  • HTTP/HTTPS web traffic
  • FTP file transfers
  • SMTP/IMAP email
  • BitTorrent P2P traffic
  • SSH connections
  • DNS queries
  • Custom application protocols

2. Authentication Support

SOCKS5 supports multiple authentication methods:

  • No authentication — Open access (risky for public proxies)
  • Username/password — Basic credential-based access (RFC 1929)
  • GSS-API — Enterprise-grade authentication using Kerberos

3. UDP Support

Unlike SOCKS4 and HTTP proxies, SOCKS5 can handle UDP traffic through the UDP ASSOCIATE command. This enables:

  • Real-time gaming connections
  • Voice and video calls
  • DNS resolution through the proxy
  • Streaming media

4. Remote DNS Resolution

SOCKS5 can resolve DNS on the proxy server side, preventing DNS leaks that could reveal your actual location. This is crucial for privacy-sensitive operations.

5. IPv6 Compatibility

SOCKS5 natively supports IPv6 addresses, making it future-proof as the internet transitions from IPv4.

Top Use Cases for SOCKS5 Proxies

1. Web Scraping with Enhanced Privacy

While HTTP proxies are more common for web scraping, SOCKS5 proxies offer better privacy because they don’t add identifying headers to your requests.

import requests

Using SOCKS5 proxy with requests

proxies = {

'http': 'socks5h://user:pass@proxy.example.com:1080',

'https': 'socks5h://user:pass@proxy.example.com:1080'

}

The 'h' in socks5h means DNS resolution happens on the proxy side

response = requests.get('https://httpbin.org/ip', proxies=proxies)

print(response.json())

2. P2P and Torrenting

SOCKS5 is the preferred proxy type for BitTorrent clients because it supports both TCP (for tracker connections) and UDP (for DHT and peer communication).

3. Gaming

Online gaming requires low-latency UDP connections. SOCKS5 proxies can route game traffic while changing your apparent location — useful for accessing region-locked game servers.

4. Bypassing Firewalls

SOCKS5’s protocol-agnostic nature makes it effective at bypassing network firewalls that only inspect HTTP traffic. The firewall sees a single TCP connection to the proxy server rather than the actual destination.

5. Email Operations

SOCKS5 can handle SMTP and IMAP connections, making it useful for email marketing operations that need IP rotation without using standard HTTP proxies.

6. SSH Tunneling

Developers often chain SOCKS5 proxies with SSH tunnels for secure remote access:

# Create a SOCKS5 proxy through an SSH tunnel

ssh -D 1080 -N user@remote-server.com

All traffic routed through localhost:1080 goes through the SSH tunnel

Setting Up a SOCKS5 Proxy

Python with PySocks

import socks

import socket

import requests

Method 1: Using requests with SOCKS5

proxies = {

'http': 'socks5h://username:password@proxy.example.com:1080',

'https': 'socks5h://username:password@proxy.example.com:1080'

}

response = requests.get('https://api.ipify.org?format=json', proxies=proxies)

print(f"IP through SOCKS5: {response.json()['ip']}")

Method 2: Setting up a global SOCKS5 proxy

socks.set_default_proxy(socks.SOCKS5, "proxy.example.com", 1080,

username="user", password="pass")

socket.socket = socks.socksocket

Now all socket connections go through SOCKS5

import urllib.request

response = urllib.request.urlopen("https://httpbin.org/ip")

print(response.read().decode())

Node.js with socks-proxy-agent

const { SocksProxyAgent } = require('socks-proxy-agent');

const axios = require('axios');

const agent = new SocksProxyAgent('socks5://user:pass@proxy.example.com:1080');

axios.get('https://httpbin.org/ip', {

httpAgent: agent,

httpsAgent: agent

}).then(response => {

console.log('IP:', response.data.origin);

});

cURL Command Line

# Using SOCKS5 with cURL

curl --socks5-hostname user:pass@proxy.example.com:1080 https://httpbin.org/ip

The --socks5-hostname flag ensures DNS resolution happens on the proxy side

Use --socks5 if you want local DNS resolution instead

Browser Configuration (Firefox)

Firefox has native SOCKS5 support:

  1. Open Settings → Network Settings → Manual Proxy Configuration
  2. Enter SOCKS Host and Port
  3. Select SOCKS v5
  4. Check “Proxy DNS when using SOCKS v5” to prevent DNS leaks

Setting Up Your Own SOCKS5 Server with Dante

# Install Dante SOCKS server on Ubuntu

sudo apt-get install dante-server

Configure /etc/danted.conf

logoutput: syslog

internal: eth0 port = 1080

external: eth0

socksmethod: username

client pass {

from: 0.0.0.0/0 to: 0.0.0.0/0

log: error

}

socks pass {

from: 0.0.0.0/0 to: 0.0.0.0/0

protocol: tcp udp

log: error

}

SOCKS5 for Web Scraping

While HTTP proxies are more commonly associated with web scraping, SOCKS5 proxies have specific advantages for certain scraping scenarios.

When to Use SOCKS5 for Scraping

  1. Stealth scraping — SOCKS5 doesn’t inject headers that could reveal proxy usage
  2. Non-HTTP APIs — Some services use raw TCP protocols for data delivery
  3. WebSocket connections — SOCKS5 handles WebSocket traffic natively
  4. Combined scraping operations — When your pipeline also needs FTP or email access

SOCKS5 with Scrapy

# Install the SOCKS5 middleware

pip install scrapy-socks5

settings.py

DOWNLOADER_MIDDLEWARES = {

'scrapy_socks5.Socks5DownloaderMiddleware': 1,

}

SOCKS5_PROXY = 'socks5://user:pass@proxy.example.com:1080'

SOCKS5 with aiohttp (Async Scraping)

import aiohttp

from aiohttp_socks import ProxyConnector

async def scrape_with_socks5(url):

connector = ProxyConnector.from_url('socks5://user:pass@proxy.com:1080')

async with aiohttp.ClientSession(connector=connector) as session:

async with session.get(url) as response:

return await response.text()

Performance Comparison for Scraping

MetricHTTP ProxySOCKS5 Proxy
Connection overheadLowerSlightly higher (handshake)
Data transfer speedEqualEqual
Header manipulationProxy may modifyNo modification
Caching supportYesNo
Detection by targetPossible (via headers)Harder to detect

For most web scraping tasks, the choice between HTTP and SOCKS5 makes little practical difference. The IP quality (residential vs datacenter) matters far more than the proxy protocol.

SOCKS5 Proxy Chaining

You can chain multiple SOCKS5 proxies together for additional anonymity:

# Using proxychains to chain multiple SOCKS5 proxies

/etc/proxychains.conf

dynamic_chain

proxy_dns

[ProxyList]

socks5 proxy1.com 1080 user1 pass1

socks5 proxy2.com 1080 user2 pass2

socks5 proxy3.com 1080 user3 pass3

# Python proxy chaining with PySocks

import socks

import socket

Chain: You -> Proxy 1 -> Proxy 2 -> Destination

socks.set_default_proxy(socks.SOCKS5, "proxy1.com", 1080)

socket.socket = socks.socksocket

Now configure a second hop

(requires proxychains or similar tool for true chaining)

Each proxy in the chain only sees the adjacent nodes:

  • Proxy 1 knows your IP but not the destination
  • Proxy 2 knows Proxy 1 and the destination, but not your IP
  • The destination only sees Proxy 2’s IP

This is conceptually similar to how Tor works, but with servers you control.

Security Considerations

What SOCKS5 Does NOT Provide

  • Encryption — SOCKS5 itself doesn’t encrypt traffic. For encryption, pair it with SSH tunneling or use it over a TLS connection.
  • Data integrity — The proxy doesn’t verify that data hasn’t been tampered with.
  • Complete anonymity — While it hides your IP from the destination, the proxy server operator can see your traffic.

Best Security Practices

  1. Always use authentication — Never run an open SOCKS5 proxy
  2. Add encryption — Combine with SSH tunnels or VPN for encrypted transit
  3. Use socks5h — The “h” variant resolves DNS remotely, preventing DNS leaks
  4. Choose trusted providers — The proxy operator can see all unencrypted traffic
  5. Monitor for leaks — Test with tools like our browser fingerprint tester to ensure no identifying information leaks

SOCKS5 over SSH (Encrypted SOCKS5)

# Create an encrypted SOCKS5 proxy tunnel

ssh -D 9050 -C -N user@your-server.com

-D 9050: Create SOCKS5 proxy on local port 9050

-C: Enable compression

-N: No remote command execution

Configure applications to use socks5://localhost:9050

How to Choose a SOCKS5 Proxy Provider

Essential Features

  • Authentication support — Username/password minimum
  • UDP support — True SOCKS5, not just SOCKS5-over-HTTP
  • Low latency — Under 100ms for nearby servers
  • Multiple locations — Global server distribution
  • No logging policy — Provider shouldn’t store connection logs

Pricing Expectations

Provider TypePrice RangeNotes
Shared SOCKS5$2-5/monthMultiple users per IP
Dedicated SOCKS5$5-15/month per IPExclusive use
Residential SOCKS5$5-15/GBResidential IPs with SOCKS5
Self-hostedServer costs onlyFull control

FAQ

Is SOCKS5 faster than a VPN?

Generally yes. SOCKS5 proxies don’t encrypt traffic by default, so they have less overhead than VPNs which must encrypt and decrypt all data. This makes SOCKS5 faster for tasks where encryption isn’t critical. However, this speed advantage comes at the cost of security. For a deeper comparison, see our proxy vs. VPN guide.

Is SOCKS5 safe to use?

SOCKS5 is safe when used properly with authentication and a trusted provider. However, since it doesn’t encrypt traffic by default, sensitive data (passwords, financial information) could be intercepted if the proxy operator is malicious. For sensitive operations, pair SOCKS5 with SSH tunneling or use HTTPS connections through the proxy.

Can SOCKS5 proxies be detected?

SOCKS5 connections themselves are harder to detect than HTTP proxies because they don’t inject headers or modify traffic. However, the IP address used can still be identified as a proxy if it belongs to a known datacenter range. Residential proxies with SOCKS5 support offer the best combination of stealth and protocol flexibility.

What’s the difference between socks5 and socks5h?

The “h” in socks5h means DNS resolution happens on the proxy server (remote DNS). With plain socks5, DNS is resolved locally on your machine before the connection is made through the proxy. Always use socks5h for privacy-sensitive tasks to prevent DNS leaks that could reveal the websites you’re visiting.

Do all applications support SOCKS5?

Most modern applications support SOCKS5, including web browsers, email clients, FTP clients, and torrent clients. For applications that don’t natively support SOCKS5, you can use tools like proxychains on Linux or proxifier on Windows to force any application through a SOCKS5 proxy.

Want to learn more about proxy protocols? Explore our proxy glossary or read our comparison of SOCKS5 vs. HTTP proxies.

Scroll to Top