A DNS leak happens when your DNS lookups bypass your proxy or VPN and go out through your regular internet connection, letting anyone watching your computer or your DNS server see which names you look up, even while your traffic goes through the proxy.
A DNS leak can happen when an application resolves hostnames itself instead of sending them through the proxy, for example when it sends traffic through a SOCKS5 proxy but still resolves hostnames locally. The Tor Project documents one way to test this: its TestSocks option logs a warning for each SOCKS connection that leaks a DNS request.
How to Prevent DNS Leaks with a Proxy
- Let the SOCKS proxy resolve names: In curl,
socks5h://andsocks4a://have the proxy resolve the hostname, whilesocks5://andsocks4://resolve it locally. - Check browser settings: Firefox's proxyDNS setting sends DNS lookups through a SOCKS proxy. Since Firefox 128, it is on by default for SOCKS5. Earlier versions defaulted to off.
- HTTP proxies receive the hostname: For HTTPS sites, the client sends the destination to the proxy as
CONNECT host:port, and the proxy opens the connection to that host.