Skip to content
Glossary

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?
Only if the client sends the hostname rather than an address. RFC 1928 allows both. In curl and Python requests, socks5:// resolves on your machine and socks5h:// sends the name for the proxy to resolve. Both return the same page, so check the scheme, not the result.
Can an HTTP proxy leak DNS?
Not for the requests it carries: a CONNECT request and an absolute-form GET both hand the hostname to the proxy. Leaks through an HTTP proxy come from traffic that bypasses it, such as a hostname matched by no_proxy, a library that ignores the proxy setting, or a browser feature that resolves names on its own.
Does DNS over HTTPS fix a DNS leak?
It encrypts the query between your machine and the resolver you picked, so your network can no longer read it. The lookup still happens on your machine, from your address, so the resolver operator still learns the hostname and the answer is still chosen for your location rather than the exit's. Resolving at the proxy is the fix; DoH changes who can watch.

Sources

  1. RFC 1928: SOCKS Protocol Version 5, the ATYP byte and the domain-name address type X'03'
  2. curl manual: --socks5-hostname and the socks5h:// scheme, where the proxy resolves the hostname
  3. Requests documentation: socks5 resolves on the client, socks5h on the proxy
  4. RFC 8484: DNS Queries over HTTPS (DoH)
  5. RFC 9110: HTTP Semantics, absolute-form request targets sent to a forward proxy

All terms, A to Z