Are you an LLM? You can read better optimized documentation at /en\wiki\socks.md for this page in Markdown format
SOCKS protocol
SOCKS (Socket Secure) is a proxy protocol standard used widely across network applications. sing-box provides complete SOCKS support, including SOCKS4, SOCKS4a and SOCKS5.
Characteristics
- 📜 A real standard: the proxy protocol defined in RFC 1928
- 🔄 Bidirectional: connections are relayed both ways between client and proxy server
- 🌍 Universal: almost every application understands SOCKS
- 📡 TCP/UDP support: SOCKS5 handles both TCP and UDP
- 🔐 Authentication: SOCKS5 supports several authentication methods
Configuration examples
SOCKS5 proxy
json
{
"outbounds": [
{
"type": "socks",
"tag": "socks5-out",
"server": "proxy.example.com",
"server_port": 1080,
"version": "5",
"username": "your-username",
"password": "your-password"
}
]
}SOCKS5 without authentication
json
{
"outbounds": [
{
"type": "socks",
"tag": "socks5-no-auth-out",
"server": "proxy.example.com",
"server_port": 1080,
"version": "5"
}
]
}SOCKS4 proxy
json
{
"outbounds": [
{
"type": "socks",
"tag": "socks4-out",
"server": "proxy.example.com",
"server_port": 1080,
"version": "4",
"username": "your-username"
}
]
}SOCKS5 over TLS
json
{
"outbounds": [
{
"type": "socks",
"tag": "socks5-tls-out",
"server": "proxy.example.com",
"server_port": 1080,
"version": "5",
"username": "your-username",
"password": "your-password",
"tls": {
"enabled": true,
"server_name": "proxy.example.com"
}
}
]
}Comparing versions
SOCKS4
- Features: the oldest version, TCP only
- Authentication: none, or username based
- DNS: the client resolves domain names
- Compatibility: works with old systems
SOCKS4a
- Features: an extension of SOCKS4
- DNS: the proxy server resolves domain names
- Compatibility: supported by old systems
- Limits: still no UDP
SOCKS5 (recommended)
- Features: the newest version, the most complete
- Authentication:
- None (00)
- GSSAPI (01)
- Username/password (02)
- Protocol support: both TCP and UDP
- DNS: the proxy server resolves domain names
- Address types:
- IPv4
- Domain names
- IPv6
Advanced configuration
Proxy chain
json
{
"outbounds": [
{
"type": "socks",
"tag": "socks5-first",
"server": "proxy1.example.com",
"server_port": 1080,
"version": "5",
"username": "user1",
"password": "pass1"
},
{
"type": "socks",
"tag": "socks5-second",
"server": "proxy2.example.com",
"server_port": 1080,
"version": "5",
"username": "user2",
"password": "pass2"
},
{
"type": "urltest",
"tag": "auto",
"outbounds": ["socks5-first", "socks5-second"],
"url": "http://www.gstatic.com/generate_204",
"interval": 300
}
]
}UDP proxy configuration
json
{
"inbounds": [
{
"type": "socks",
"tag": "socks5-in",
"listen": "127.0.0.1",
"listen_port": 1080,
"version": "5",
"users": [
{
"username": "your-username",
"password": "your-password"
}
],
"udp_forward": {
"enabled": true,
"listen": "127.0.0.1",
"listen_port": 1081
}
}
]
}Use cases
Application proxying
- Web browser proxy settings
- Mail client proxying
- Download tool proxying
- Game acceleration (some games)
System proxy
- System-wide proxying
- Proxying specific applications
- Per-app proxy rules
Network debugging
- Network testing and analysis
- Traversing firewalls
- Network debugging tools
Pros and cons
Pros
- Highly standardized
- Universal, with broad support
- Simple to configure and easy to use
- Supports both TCP and UDP
- Includes authentication
Cons
- Traffic characteristics are fairly obvious
- No built-in encryption (needs extra configuration)
- May be blocked on restricted networks
- No anti-detection capability
- Easily identified as proxy traffic
Configuration guide
Browsers
- Chrome/Edge: Settings → Advanced → System → Open your computer's proxy settings
- Firefox: Options → General → Network Settings → Manual proxy configuration
- Safari: System Settings → Network → Advanced → Proxies
System settings
Windows
bash
# Configure the system proxy with netsh
netsh winhttp set proxy proxy-server="socks5=127.0.0.1:1080"macOS
bash
# Configure the proxy with networksetup
networksetup -setsocksfirewallproxy Wi-Fi 127.0.0.1 1080Linux
bash
# Set environment variables
export http_proxy=socks5://127.0.0.1:1080
export https_proxy=socks5://127.0.0.1:1080Applications
- Most network applications support SOCKS proxy settings
- Some applications need special configuration or plugins
- Games may require UDP proxy support
Security considerations
Encrypted transport
- Wrap SOCKS traffic in TLS
- Use HTTPS or another encrypted tunnel
- Avoid sending sensitive data in the clear
Authentication
- Use strong usernames and passwords
- Rotate credentials regularly
- Enable an appropriate authentication method
Access control
- Restrict which IP ranges may connect
- Monitor and limit traffic
- Configure firewall rules
Performance tuning
Connection handling
- Use connection pooling to cut setup overhead
- Configure sensible timeouts
- Optimize DNS resolution
Load balancing
- Use several SOCKS proxy servers
- Configure failover
- Monitor server health
Troubleshooting
Connection failures
- Check the server address and port
- Verify the credentials
- Confirm network connectivity
- Check firewall settings
Authentication errors
- Verify the username and password
- Check which authentication methods are supported
- Confirm the account status
- Reset the credentials
Performance problems
- Check server load
- Optimize network routing
- Adjust timeout settings
- Use load balancing