Your cart is currently empty!
SOCKS5 versus HTTP CONNECT for collection traffic
Two endpoints, one proxy, no explanation
Most proxy vendors hand you the same pool two ways. One endpoint says http:// and one says socks5://, often on different ports of the same host, with the same credentials. The dashboard doesn’t say which to use, and neither does the setup guide, so collectors end up on whichever one the first example happened to show.
Usually that works, because for ordinary HTTPS scraping both protocols deliver the same thing: your request leaves from the proxy’s exit IP. But they get there in different ways, and the differences show up at inconvenient moments. A browser that refuses the SOCKS endpoint’s credentials. A resolver leak on one scheme that the other doesn’t have. A proxy error that your retry logic mistakes for a target error. A UDP-based protocol that silently goes direct. A library that needs an extra package for one protocol and not the other.
This piece explains both at the level you need to make the choice deliberately. How a plain HTTP proxy forwards requests. How the CONNECT method builds a tunnel for HTTPS. How SOCKS5 negotiates a connection. Where each resolves DNS, how each handles authentication and UDP, how their failures look to your code, and which clients support what. It ends with how we choose per workload.
The DNS leak guide in this series covers one consequence in depth, the difference between local and remote resolution on SOCKS5, so that part is kept short here. The proxy-types guide covers residential, datacenter and mobile pools, which is a separate question from the protocol you use to reach them. Any pool type can be offered over either protocol.
We run collection traffic over both protocols, through our own mobile proxy farm and through bought pools, and the protocol decision has caused more confusing incidents than its simplicity suggests. None of what follows involves benchmarks. It’s about how the protocols are specified and how the common tools implement them.
What a proxy protocol has to do
Strip away the details and a proxy protocol has one job: let a client tell a proxy where it wants to connect, and then carry the traffic.
That breaks into a handful of questions every protocol has to answer. How does the client name the destination, as a hostname or an IP address? Who resolves a hostname into an address? How does the client prove it’s allowed to use the proxy? What happens when the proxy can’t reach the destination, and how does the client find out? Which kinds of traffic can be carried: only HTTP, any TCP stream, or UDP as well? And how much of the traffic can the proxy see or change?
HTTP proxies and SOCKS5 answer these questions differently because they were designed at different layers. An HTTP proxy speaks HTTP. It understands requests and responses, and even when it’s just tunnelling, the setup is an HTTP exchange. SOCKS5 sits below the application protocol. It sets up a connection and then relays bytes without knowing or caring what they mean.
That layering explains most of the practical differences. An HTTP proxy can do HTTP-level things, such as adding headers, caching, or refusing particular URLs, when it can see the traffic, and it reports errors as HTTP status codes. SOCKS5 can carry any TCP protocol, and in principle UDP, but it can’t do anything HTTP-specific, and its errors are compact binary reply codes that client libraries translate into exceptions of varying helpfulness.
For modern collection, where nearly everything is HTTPS, the gap narrows, because an HTTP proxy handling HTTPS isn’t looking at HTTP at all after the tunnel is up. The remaining differences are in setup, authentication, DNS, UDP and client support.
Plain HTTP through an HTTP proxy
For an unencrypted http:// URL, a client configured with an HTTP proxy doesn’t open a connection to the target at all. It opens a connection to the proxy and sends the request there, with one change: the request line carries the full URL instead of just the path. So instead of GET /products/42 HTTP/1.1 it sends GET http://example.com/products/42 HTTP/1.1, along with the usual headers.
The proxy reads the full URL, opens its own connection to the target, forwards the request, and relays the response. Along the way it’s a full participant in the HTTP exchange. It can read every header and body in both directions, add headers of its own, cache responses, rewrite anything, or refuse the request based on the URL. Some proxies add headers like Via or X-Forwarded-For that tell the target a proxy was involved and, in the worst case, the client’s original address. Commercial scraping proxies generally don’t, but it’s worth checking by sending a request to an endpoint that echoes headers back.
Authentication rides along as a Proxy-Authorization header on each request, usually with the Basic scheme, which is the username and password base64-encoded, not encrypted. On a plain HTTP connection to the proxy, anyone on the path between you and the proxy can read it.
Plain HTTP targets are rare in collection now. Most sites redirect to HTTPS, and many APIs refuse plain HTTP entirely. But the mode still matters in two places. Some internal or legacy endpoints are HTTP-only. And some clients, when misconfigured, send HTTPS URLs to an HTTP proxy in this absolute-form style instead of using CONNECT, which leaves the proxy to make the TLS connection on your behalf. That’s unusual, but when it happens the proxy sees your traffic in the clear.
CONNECT: the tunnel for HTTPS
For https:// URLs, an HTTP proxy works differently. The client can’t send the request itself to the proxy without breaking end-to-end encryption, so it asks the proxy for a tunnel instead.
The client connects to the proxy and sends a CONNECT request naming the host and port, like CONNECT example.com:443 HTTP/1.1, with a Host header and, if needed, Proxy-Authorization. The proxy opens a TCP connection to that host and port. If it succeeds, it replies with a 200 status, and from then on it relays bytes in both directions without interpreting them. The client performs the TLS handshake with the target through that tunnel, and everything after that is encrypted between the client and the target.
What the proxy can see is limited to what’s in the CONNECT request and the connection metadata: the hostname and port, the timing, and the volume of bytes. It can also read the server name in the TLS handshake as it passes, which normally matches the CONNECT hostname. It can’t see URLs, headers or bodies, unless the client has been set up to trust a certificate the proxy controls and the proxy is deliberately intercepting TLS, which some corporate proxies do and scraping vendors shouldn’t.
Two practical details. Many HTTP proxies restrict CONNECT to a short list of ports, typically 443, because an open CONNECT to any port turns the proxy into a general-purpose relay. If you need to reach something on an unusual port, check whether the proxy allows it. And the CONNECT exchange is a single request and response, so the setup cost on top of the TCP connection to the proxy is one round trip, with authentication included in that same request.
CONNECT tunnels carry any TCP protocol in principle. WebSockets over TLS work through them, since they start as HTTPS. Non-web protocols work too, if the proxy allows the port.
SOCKS5, step by step
SOCKS5 is specified in RFC 1928, with username and password authentication in RFC 1929. It’s a small binary protocol with a fixed sequence.
The client connects to the proxy and sends a greeting listing the authentication methods it supports, such as “no authentication” and “username and password.” The proxy picks one and replies. If the method is username and password, the client sends the credentials in a sub-negotiation and the proxy replies with success or failure. Then the client sends a request with a command, an address type, an address and a port. The proxy replies with a status code and the address it bound, and if the status is success, the connection is ready and the proxy relays bytes.
There are three commands. CONNECT asks the proxy to open a TCP connection to the destination, which is what nearly all collection traffic uses. BIND asks the proxy to listen for an incoming connection, a rarely used feature from the days of active-mode FTP. UDP ASSOCIATE sets up UDP relaying, covered in its own section below.
The address type is where SOCKS5 gives the client a choice HTTP CONNECT doesn’t. The destination can be sent as an IPv4 address, an IPv6 address, or a domain name. If the client sends a domain name, the proxy resolves it. If the client resolves it first and sends an address, the client’s own resolver did the work. That choice is what the socks5 versus socks5h distinction in curl and Python libraries controls, and it’s the root of the resolver leak covered in the DNS guide.
Once the connection is up, SOCKS5 is a pure byte relay. It doesn’t know whether the bytes are HTTP, TLS, or anything else, so it can’t add headers, cache, or filter by URL. For HTTPS, the result looks the same as a CONNECT tunnel: an encrypted stream between client and target, with the proxy seeing only the destination and the volume.
Older versions exist. SOCKS4 supports only IPv4 addresses and has no real authentication. SOCKS4a added hostnames. When a vendor offers SOCKS, it’s almost always SOCKS5.
Where DNS gets resolved
The DNS question matters because the resolver that turns a hostname into an address determines which network makes the lookup, and a lookup made from your own network, while the connection goes through the proxy, reveals your infrastructure’s resolver to whoever operates the target’s DNS and can return answers tailored to your location rather than the exit’s.
With HTTP CONNECT, the client puts the hostname in the CONNECT request, and the proxy resolves it. That’s the default in essentially every client, and it means HTTP proxies are resolver-safe for the main request as long as the client actually uses CONNECT. The DNS guide covers the exceptions, which live in secondary code paths such as health checks, connection pools and retry fallbacks that resolve on their own before or instead of going through the proxy.
With SOCKS5, resolution depends on the address type the client sends, and clients differ in their defaults. In curl, socks5:// resolves locally and sends an address, while socks5h:// sends the hostname for the proxy to resolve. Python’s requests with PySocks follows the same convention. Other tools call it “remote DNS” or have a flag for it. A one-character difference in the proxy URL decides whether your lookups leave from your own network.
There’s a second, subtler effect. When the proxy resolves, it resolves from the exit’s network, so geographically aware DNS returns addresses appropriate to the exit’s location. When the client resolves locally, it can get an address for a data centre near the client rather than near the exit, and the connection then goes from the exit to that distant address. The page may still load, but content that depends on which edge server answered, such as regional pricing or language defaults, can differ from what a real visitor at the exit’s location would see.
The rule is simple. With SOCKS5, use the remote-resolution form every time, and verify it with a capture. With HTTP proxies, you get remote resolution by default, and the thing to verify is that nothing in your client bypasses the proxy to resolve.
Authentication and what the proxy sees
Both protocols carry credentials in a form that isn’t encrypted by the protocol itself.
HTTP proxies use the Proxy-Authorization header, almost always with the Basic scheme. It’s base64 encoding, which anyone can reverse. For plain HTTP requests, it’s sent with every request. For CONNECT, it’s sent in the CONNECT request, once per tunnel. If authentication fails, the proxy replies with 407 Proxy Authentication Required, which is a clear and distinct signal.
SOCKS5 username and password authentication sends the credentials as plain bytes in the sub-negotiation. There’s no encoding at all, and a failure is a single status byte, which libraries report in their own ways.
In both cases, the credentials cross the network between your collector and the proxy in readable form, unless that connection is itself encrypted. For HTTP proxies, some clients support connecting to the proxy over TLS, usually written as an https:// proxy URL, which wraps the whole exchange, including the credentials and the CONNECT request, in encryption to the proxy. curl supports this, and so do several other clients. SOCKS5 has no equivalent in common use, so SOCKS credentials are exposed to anyone who can observe the path to the proxy.
How much that matters depends on where your collectors run. On a private network or a trusted cloud path to a vendor’s gateway, it’s usually acceptable. Across networks you don’t control, such as collectors on third-party hosts connecting to a proxy over the public internet, it’s a real exposure, and IP allow-listing on the vendor side, or a TLS connection to an HTTP proxy, reduces it.
Many vendors encode session and targeting options in the username, such as country, city or a sticky session ID. That works identically on both protocols, since both carry a username. It also means the username is sensitive, since it reveals what you’re targeting.
Keep proxy credentials out of logs. Proxy URLs with embedded credentials end up in error messages and debug output more often than anyone intends, as the credentials guide in this series describes.
UDP, QUIC and what neither covers
The most concrete capability difference between the two protocols is UDP. SOCKS5 defines it. HTTP CONNECT doesn’t.
SOCKS5’s UDP ASSOCIATE command asks the proxy to relay UDP datagrams. The client keeps a TCP control connection open, and sends UDP packets to a relay address the proxy returns, each wrapped in a small SOCKS header naming the destination. When the control connection closes, the association ends. That’s enough to carry DNS queries, some streaming protocols, and other UDP traffic through the proxy.
In practice, UDP support is patchy on both ends. Not every SOCKS5 server implements UDP ASSOCIATE, and vendors that do may restrict it. Client support is thinner still: most HTTP libraries never use it, since HTTP over TCP is all they need, and the tools that do use it are mostly general-purpose networking utilities. If a workload genuinely needs UDP through the proxy, confirm support with the specific vendor and client before designing around it.
HTTP CONNECT is TCP only. There’s a newer standard for proxying UDP over HTTP, defined for HTTP/3 in RFC 9298, but it isn’t something typical scraping proxies offer.
This matters for collection mostly through what goes around the proxy. HTTP/3 runs over QUIC, which is UDP. When a browser is configured with a TCP proxy, it generally falls back to HTTP/2 or HTTP/1.1 over TCP, so the traffic stays in the proxy. But any component that tries UDP on its own, such as WebRTC in a real browser session or a custom DNS resolver, can send packets straight out of your own network, bypassing a proxy that only carries TCP. The DNS guide covers WebRTC as a separate leak vector.
The honest summary: for HTTPS collection, neither protocol’s UDP story matters, as long as you’ve made sure nothing tries to use UDP around the proxy. For workloads that need UDP, SOCKS5 is the only one of the two that can carry it, and whether it actually will depends on the vendor.
Errors: telling proxy failures from target failures
A collector’s retry and error-handling logic depends on knowing whether a failure came from the proxy or from the target. The two protocols make that easier or harder in different ways.
With an HTTP proxy, a CONNECT failure comes back as an HTTP status from the proxy before any TLS happens. A 407 means authentication failed. A 502 or 503 usually means the proxy couldn’t reach the target or had no exit available. Some vendors use a 403 or a custom status to say a destination is blocked by their policy. Clients surface these differently. Some raise a specific proxy error exception, while others raise a generic connection error with the status in the message. Once the tunnel is up, any HTTP status you see comes from the target, since the proxy can’t see inside the tunnel.
That distinction is the key one. A 403 from the target means the site refused you. A 403 in response to CONNECT means the proxy refused to open the tunnel. Error handling that treats both the same, slowing down the target in response to a proxy policy block, or rotating proxies in response to a site block, does the wrong thing in both cases. The error taxonomy guide in this series covers building this distinction into a collector.
With SOCKS5, failures come back as reply codes in the connection setup: general failure, connection not allowed by ruleset, network unreachable, host unreachable, connection refused, TTL expired, command not supported, address type not supported. Libraries map these into exceptions, sometimes preserving the code and sometimes not. Authentication failure happens even earlier, in the sub-negotiation. As with CONNECT, anything after setup comes from the target.
Log the protocol-level outcome separately from the target’s response. A field that says “proxy setup failed, code X” versus “target returned status Y” is the difference between a quick diagnosis and a long one, whichever protocol you use.
What your client libraries actually support
Support varies more than people expect, and it’s often the deciding factor.
curl supports HTTP proxies, HTTPS proxies where the connection to the proxy is itself TLS, and SOCKS4, SOCKS4a, SOCKS5 and SOCKS5 with remote resolution, all selected by the proxy URL scheme. It’s the most complete reference client and the best tool for testing a vendor endpoint by hand.
Python’s requests supports HTTP proxies natively. SOCKS needs the optional PySocks dependency, installed through the requests[socks] extra, after which socks5:// and socks5h:// URLs work. httpx also supports HTTP proxies natively and SOCKS through an optional extra. aiohttp supports HTTP proxies natively, and SOCKS through a separate third-party connector package. Scrapy supports HTTP proxies through its built-in proxy middleware and needs third-party components for SOCKS.
Browsers have their own limits. Chromium supports SOCKS5 proxies but doesn’t support SOCKS5 username and password authentication, which is why an authenticated SOCKS endpoint that works in curl can fail in Playwright or Puppeteer running Chromium. HTTP proxies with credentials work, and Playwright’s proxy option accepts a username and password for them. With Chromium, the practical choices for authenticated SOCKS are an IP-allow-listed endpoint with no credentials, or a local relay that accepts unauthenticated connections and forwards them to the authenticated proxy.
Go’s standard HTTP transport accepts HTTP, HTTPS and SOCKS5 proxy URLs. In Node, many HTTP clients support HTTP proxies through agents, with SOCKS available through separate agent packages.
Environment variables add another layer of variation. HTTP_PROXY, HTTPS_PROXY, ALL_PROXY and NO_PROXY are conventions rather than a standard, and tools interpret them differently, including case sensitivity, whether SOCKS URLs are accepted, and how NO_PROXY patterns match. Set proxies explicitly in code for collectors, rather than relying on environment variables that behave differently in each tool.
Setup cost and connection reuse
Without quoting benchmarks, the protocol structure tells you where setup cost comes from.
Both protocols start with a TCP connection to the proxy. HTTP CONNECT then needs one request and response to set up the tunnel, with authentication in the same request. SOCKS5 with username and password needs three exchanges: the greeting, the authentication sub-negotiation and the connect request, each waiting for the proxy’s reply before the next. Without authentication, it’s two. Then, for HTTPS, the TLS handshake with the target runs through the tunnel in both cases, and the proxy has to make its own connection to the target during setup.
So on a fresh connection, SOCKS5 with credentials takes more round trips between the collector and the proxy than CONNECT does. Whether that’s noticeable depends on the latency to the proxy. For a proxy gateway close to your collectors, it’s small. For one on another continent, each extra round trip adds up across many fresh connections.
Connection reuse makes most of this disappear. A client that keeps connections alive reuses the same tunnel for many requests to the same host, paying the setup cost once. HTTP/2 multiplexes many requests over one connection. The setup difference matters most for collectors that open a fresh connection per request, often because every request is meant to use a different exit IP.
That’s the real trade-off with rotation. Vendors that rotate the exit per connection make connection reuse and rotation opposites: reuse keeps the same exit, and a fresh connection gets a new one. If your job wants a new IP per request, you’re paying full setup cost per request on either protocol, and SOCKS5’s extra round trips are part of that cost. If your job uses sticky sessions, reuse is fine and the protocols cost about the same.
What the target sees
It’s worth being clear about what the protocol choice doesn’t change, because there’s a lot of folklore suggesting one is harder to detect than the other.
For HTTPS traffic, the target sees a connection from the proxy’s exit IP, followed by your client’s TLS handshake and your client’s HTTP requests. The proxy protocol between your collector and the proxy is invisible to the target. A CONNECT tunnel and a SOCKS5 connection deliver identical bytes to the target, because in both cases the proxy is just relaying your client’s traffic from its own address.
So the things bot-management systems look at, such as the exit IP’s reputation, the client’s TLS characteristics, header order and behaviour over time, are the same either way. Switching from HTTP to SOCKS5, or back, doesn’t make a client look more or less like a browser, and it doesn’t change how an IP is scored. Explaining how those systems classify traffic is covered in the detection guides in this series. Nothing about proxy protocol choice is a way around them, and no protocol makes traffic undetectable.
The exceptions are configuration mistakes. An HTTP proxy that adds Via or X-Forwarded-For headers to plain HTTP requests tells the target a proxy was involved. A SOCKS5 setup that resolves locally makes DNS queries from your own network, which the target’s DNS operator can see. A UDP path that bypasses the proxy reveals your real address to anything that receives it. Each of these is about getting the setup right, and none is inherent to one protocol.
The honest framing: protocol choice is an engineering decision about capability, compatibility and failure handling, and it has no bearing on stealth.
Choosing per workload, and what to do on Monday
Here’s how we choose.
For HTTPS collection with HTTP clients and browsers, which is most collection, use the HTTP endpoint with CONNECT. It’s supported natively by nearly every client, it resolves DNS at the proxy by default, its errors are HTTP statuses that are easy to classify, its setup is one round trip, and authenticated HTTP proxies work in Chromium. If the path to the proxy crosses networks you don’t trust, use a TLS connection to the proxy where the client supports it.
Use SOCKS5 when you need something only it provides: UDP relay, confirmed with the vendor; non-HTTP TCP protocols on ports the HTTP proxy won’t CONNECT to; or a tool that only speaks SOCKS. When you do, use remote resolution every time, and plan around Chromium’s lack of SOCKS authentication.
Use one protocol consistently per job. Mixing them across workers in the same job means two sets of error handling and two DNS behaviours to verify.
On Monday, check which proxy URL scheme every collector actually uses, including the exact SOCKS variant. Run one request per collector through a header-echo endpoint to confirm no proxy headers are added, and capture a few seconds of traffic to confirm DNS isn’t leaving from your own network and nothing goes out over UDP. Make sure your error handling separates proxy-setup failures from target responses. And move proxy configuration out of environment variables into explicit code or config, so every tool gets the same answer.
For more on proxy infrastructure, from pool types to rotation to the gateway in front of it all, the full set of guides is at Data Research Tools.
Get new guides and videos first — join the Telegram channel.
Leave a Reply