Skip to content

How to Use a SOCKS5 Proxy: Setup, Comparisons and DNS Choices

A SOCKS5 proxy sits between an application and its destination, opening the requested connection and relaying data in both directions. It can change the IP address a destination sees, but it does not by itself encrypt traffic or make a user anonymous. This guide explains the handshake, when SOCKS5 is preferable to HTTP or a VPN, and how to verify that routing is working in Python and curl.

What SOCKS5 does — and does not do

SOCKS5 is a general-purpose relay protocol. A client connects to the proxy, agrees how to authenticate, then asks for a TCP connection or a UDP association to a named host or address. Once the proxy reaches that target, it passes bytes back and forth without needing to interpret HTTP headers, database messages or other application content. That indifference to payload format is why one endpoint can serve several kinds of compatible traffic.

The destination normally sees the proxy as the network source. That is not anonymity: cookies, signed-in accounts, browser fingerprints, request content and other signals can still identify or correlate activity. Authentication also only controls who may use the proxy; it does not encrypt relayed data. Encryption must come from another layer, such as TLS for the application or a VPN tunnel for the device.

Handshake and the socks5 versus socks5h decision

The usual sequence is: connect to the proxy, negotiate an authentication method, authenticate if required, send a command with the target host and port, then relay traffic after a status reply. Port 1080 is common for SOCKS, but the provider's configured port is authoritative.

A frequent setup error is DNS location. With socks5:// in curl or Python requests, the client resolves the hostname locally and sends the resulting address onward. With socks5h://, the hostname travels through the SOCKS connection and the proxy resolves it. The h suffix is a client convention, not a different SOCKS version, and other libraries may use different schemes or flags. Choose deliberately: local resolution can expose the name to the local resolver, while proxy-side resolution keeps that lookup on the proxy path.

SOCKS5 compared with HTTP and HTTPS proxies

HTTP proxies understand HTTP requests, so they can log, filter, cache or debug at request level. For HTTPS, an HTTP proxy commonly opens a CONNECT tunnel and TLS then runs inside it, so the proxy does not automatically see decrypted content, though it can see connection-level details such as the destination. SOCKS5 instead relays at a lower layer and can carry non-HTTP protocols as well as HTTP.

Use HTTP or HTTPS when the workload is only web traffic and you want request-level controls or straightforward client support. Use SOCKS5 when the tool expects a SOCKS interface, you need proxy-side DNS through a client that supports it, or the same path must carry both web and non-web traffic. For scraping, which is HTTP traffic, an HTTP proxy is usually the more direct interface.

SOCKS4 versus SOCKS5

SOCKS4 offers basic TCP relaying without negotiated authentication, UDP relaying, IPv6 destination addresses or a standard way to pass a hostname for proxy-side resolution. Its USERID field is not the same as SOCKS5 username/password authentication. SOCKS4a is a separate extension that added hostname handling and should not be confused with plain SOCKS4.

SOCKS5 adds authentication-method negotiation, UDP ASSOCIATE relaying, IPv6 and domain-name destination addresses. Whether a hostname is actually resolved by the proxy still depends on client configuration. For new setups, SOCKS5 is generally preferred; SOCKS4 remains relevant mainly for legacy compatibility.

SOCKS5 compared with a VPN

A SOCKS5 proxy is normally configured per application and relays that application's supported traffic. A VPN creates an encrypted tunnel for device traffic, with scope shaped by routing and split-tunnelling settings. SOCKS5 has no encryption overhead by default, but that alone does not guarantee faster performance; route, load, latency, bandwidth and connection handling also matter.

The two can be combined, and some VPN providers also offer SOCKS5 endpoints, but a SOCKS5 endpoint from a VPN company is not itself a VPN tunnel. When both are active, an application may reach the proxy through the tunnel depending on routes, DNS and client settings. That can add flexibility while also adding complexity and possible performance cost. Neither arrangement guarantees anonymity.

Set up and verify SOCKS5 in Python and curl

Use the supplied protected modules code0001 through code0005 to create and activate an isolated Python environment and install the SOCKS-capable requests package. Then obtain the proxy host and port from your provider and use protected module code0006 to send a request to an IP-echo endpoint through socks5h://. The example uses an obfuscated address; substitute the real provider values.

Verify routing by requesting the same endpoint once without the proxy and once with it: the returned addresses should differ, with the proxied response showing the proxy's egress address. Protected module code0007 shows the equivalent curl check using --proxy with a socks5h:// URL. If the addresses match, check the scheme, host, port, authentication and whether the application is actually using the proxy settings.

Command example

mkdir proxy-requests

Command example

cd proxy-requests

Command example

pip install "requests[socks]"

SOCKS5 for scraping: self-managed pool or managed API

A self-managed pool gives direct control over address selection, rotation, sessions, DNS behaviour, timeouts and retries. At scale it also requires replacing dead addresses, monitoring health, handling blocks and managing concurrency. A managed scraping service moves rotation, rendering, retries and anti-bot handling behind an API, trading some low-level control for less operations work.

For protocol choice, remember that scraping is HTTP work: SOCKS5 is justified when tooling requires it, when proxy-side DNS is otherwise unavailable, or when non-HTTP traffic must share the workflow. Before choosing, check client compatibility, DNS behaviour, routing needs and protocol support rather than assuming SOCKS5 is automatically better for web requests.

SOCKS5 versus HTTP/HTTPS proxy
FactorSOCKS5 proxyHTTP/HTTPS proxy
Protocol supportCan relay supported HTTP and non-HTTP traffic without interpreting the application protocol.Designed for HTTP traffic; HTTPS commonly uses a CONNECT tunnel.
Application awarenessDoes not parse HTTP methods, headers, status codes or message bodies.Understands HTTP semantics, supporting request-level logging, filtering, caching and debugging.
Web scraping useUseful when a browser, HTTP library or automation tool expects a SOCKS interface.Common for scraping because workloads are HTTP-based and clients often support it directly.
DNS behaviourCan support proxy-side resolution when the client passes the hostname, such as with socks5h://.Depends on proxy type, tunnelling method and client configuration.
Best choice whenClient compatibility, remote DNS or multiple application protocols are the priority.HTTP-specific controls, direct client support or request-level debugging are the priority.

HTTPS is commonly carried through a CONNECT tunnel; DNS behaviour for HTTP proxies depends on proxy type, tunnelling and client configuration.

SOCKS4 versus SOCKS5
AreaSOCKS4SOCKS5
AuthenticationNo negotiated framework; USERID is not equivalent to SOCKS5 username/password authentication.Supports method negotiation, including no authentication, username/password and GSSAPI.
TransportTCP only, primarily CONNECT, with BIND for specific inbound workflows.TCP and UDP, including CONNECT, BIND and UDP ASSOCIATE.
AddressingIPv4 destination addresses; no IPv6 in plain SOCKS4.IPv4, IPv6 or domain-name destinations.
Proxy-side DNSNo standard hostname mechanism in plain SOCKS4; SOCKS4a added one.Supports domain-name destinations, subject to client behaviour and configuration.
Typical useLegacy systems that only implement SOCKS4.New configurations needing authentication negotiation, UDP, IPv6 or modern tool support.

SOCKS4a is a separate extension and is not a feature of plain SOCKS4.

Frequently asked questions

Can I get a SOCKS5 proxy for free?

Public lists exist, but operator identity, reliability and lifespan are often unclear, so caution is warranted. A proxy reached through SSH to a server you control reduces some third-party exposure without automatically giving anonymity. Tor offers a SOCKS interface but routes and performs differently. For production scraping, managed infrastructure is generally more practical than a public list.

Are my SOCKS5 proxy credentials sent securely?

Not on the standard username/password method alone: those values travel in cleartext from client to proxy, and later HTTPS to the destination does not protect that earlier exchange. The same applies to Basic proxy authentication over HTTP. Send sensitive credentials only over a trusted path or where the service adds transport protection.

Is it legal to use a SOCKS5 proxy?

Using the protocol is not inherently unlawful. Legality depends on what you do through it, local law, authorisation and the target service's rules. Breaking a site's terms is not automatically the same as breaking the law, though it can have separate contractual or access consequences.

Can I use a SOCKS5 proxy for anything besides web scraping?

Yes. Because it relays TCP and UDP without being tied to HTTP, compatible clients can use it for other network applications, including TCP-based tools, VoIP and UDP applications. Compatibility depends on the client implementation and the proxy's supported commands, transports and settings.

curl --proxy "socks5h://45.xx.yy.zz:4289" https://httpbin.org/ip