What is a DNS leak?
Definition
A DNS leak is a name lookup that travels outside the path you intended, so a resolver you did not choose learns the hostname you were about to visit.
The request itself can go through the proxy perfectly well while the lookup that came before it did not, and nothing in the response tells you which happened. That is why this leak survives so long in working code. It is a question of who turns the hostname into an address, and the answer depends on the proxy protocol and on one character in the proxy URL.
Who resolves the name
| Setup | What the client sends the proxy | Name resolved by |
|---|---|---|
| HTTP CONNECT (HTTPS through an HTTP proxy) | CONNECT example.com:443 |
The proxy |
| HTTP forward proxy, plain HTTP | GET http://example.com/ HTTP/1.1 |
The proxy |
| SOCKS5, address type IPv4 or IPv6 | A literal address, already looked up | Your machine, before connecting |
| SOCKS5, address type domain name | The hostname itself | The proxy |
RFC 1928 gives the SOCKS5 request an address-type byte: X'01' for IPv4, X'03' for a domain name, X'04' for IPv6. The domain-name type exists so the proxy can do the lookup. Whether it is used is entirely the client’s decision, and in curl and Python’s requests the plain socks5:// scheme does not use it.
The one character, caught on the wire
We ran a minimal SOCKS5 server on 127.0.0.1:10800 that logs the command and address type of each request, then sent the same HTTPS request through it twice with curl 8.7.1 on macOS 26.6.2. The only difference is the h in the scheme. Verbose output, trimmed to the lines about the proxy:
$ curl -sv -o /dev/null -x socks5://127.0.0.1:10800 https://example.com/
* Host example.com:443 was resolved.
* SOCKS5 connect to 104.20.23.154:443 (locally resolved)
* SOCKS5 request granted.
$ curl -sv -o /dev/null -x socks5h://127.0.0.1:10800 https://example.com/
* SOCKS5 connect to example.com:443 (remotely resolved)
* SOCKS5 request granted.
And what the proxy received:
CMD=0x01 ATYP=0x01 DST=104.20.23.154:443
CMD=0x01 ATYP=0x03 DST=example.com:443
Both requests succeeded, and both returned the same page. In the first, curl asked the operating system’s resolver for example.com before a single proxied byte moved, so the lookup left from your own address to whichever resolver your network uses. The proxy only ever saw a number. Python’s requests follows the same convention and says so in its documentation: socks5:// resolves on the client, socks5h:// on the proxy. The curl guide and the Python proxy guide show the setting for each client; in Node the equivalent is an option on the agent, covered in the Node.js guide.
Captured on 21 October 2026: one request per scheme, curl 8.7.1, a local Python SOCKS5 logger with no authentication. The log lines are the server’s own record of the request bytes, not curl’s description of them.
Why it matters beyond privacy
A leaked lookup also breaks geo-targeting. Large sites answer DNS differently depending on where the resolver sits. Resolve locally, then connect through an exit node in another country, and you can land on an edge server chosen for your real location while the site geolocates the exit, so the page you get mixes the two. The symptom looks like a bad proxy and is a client setting.
Browser automation has its own version. A browser launched with a proxy may still resolve names through the operating system on some code paths, and extensions add more. Confirm by capturing traffic on your own interface: a query for the target hostname leaving your machine on port 53, or to your configured encrypted resolver, means the lookup was local. That is more reliable than any leak-test web page, which can only see the resolvers it controls.
Two neighbouring failures are often confused with this one. An address leak, where the destination sees your real address, is a different fault with a different test; a WebRTC leak is the usual browser example. And DNS over HTTPS (RFC 8484) encrypts the lookup on its way to the resolver you chose, but your machine still performs it from your address. It changes who can read the query, not which side of the proxy makes it.
Frequently asked questions
Does using a SOCKS5 proxy stop DNS leaks?
Can an HTTP proxy leak DNS?
Does DNS over HTTPS fix a DNS leak?
Sources
- RFC 1928: SOCKS Protocol Version 5, the ATYP byte and the domain-name address type X'03'
- curl manual: --socks5-hostname and the socks5h:// scheme, where the proxy resolves the hostname
- Requests documentation: socks5 resolves on the client, socks5h on the proxy
- RFC 8484: DNS Queries over HTTPS (DoH)
- RFC 9110: HTTP Semantics, absolute-form request targets sent to a forward proxy