Guides 4 min read

DNS Leaks and Proxies: How to Stop Your Real Location Leaking

Your proxy can hide your IP while your DNS lookups still go straight to your ISP. Here's how that happens, how to test for it, and the one-letter fix.

DNS leaks happen when your traffic goes through a proxy but the hostname lookups don't. Before your client can connect to example.com, something has to turn that name into an IP address. If your machine does that lookup itself, the query goes to your ISP's or your local DNS resolver, outside the proxy. The site still sees the proxy's IP, but your network learns which sites you visit, and the DNS answers you get are tuned to your real location rather than the proxy's. With proxies the fix is usually one setting.

Why DNS Leaks Matter With Proxies

  • Privacy: your ISP, office network or Wi-Fi operator can log every hostname you look up even though the connections go through the proxy.
  • Wrong geography: many sites and CDNs return different IPs depending on where the DNS query came from. Resolve locally in London and you may connect, through a US proxy, to a European edge server, which then serves the wrong country's content.
  • Detection: some sites can correlate the resolver that queried their domain with the IP that connected. A German resolver followed by a US connection is a mismatch.

Who Resolves the Hostname?

It depends on the proxy protocol:

  • HTTP proxies: the client sends the hostname to the proxy (in the CONNECT line or full URL), and the proxy resolves it. No leak by design, though some clients still do a local lookup for other reasons.
  • SOCKS5 with remote resolution: the client sends the hostname to the proxy. No leak.
  • SOCKS5 with local resolution: the client resolves the name itself and sends an IP address to the proxy. The lookup leaks.
  • SOCKS4: supports only IP addresses, so it always resolves locally. SOCKS4a added hostname support.

The SOCKS5 case is where most leaks come from, because many tools default to local resolution. See what a SOCKS5 proxy is for the protocol details.

The socks5 vs socks5h Fix

curl and Python's requests use the scheme to choose: socks5:// resolves locally, socks5h:// sends the hostname to the proxy. The h is the whole fix.

# Leaks DNS: curl resolves example.com on your machine
curl -x socks5://USERNAME:[email protected]:1080 https://example.com

# No leak: the proxy resolves it
curl -x socks5h://USERNAME:[email protected]:1080 https://example.com

In Python with requests (install the SOCKS extra first with pip install requests[socks]):

import requests

proxy = "socks5h://USERNAME:[email protected]:1080"
r = requests.get("https://api.ipify.org", proxies={"http": proxy, "https": proxy}, timeout=30)
print(r.text)

If you don't need SOCKS specifically, the simplest leak-free option is the HTTP proxy on port 8080, which always resolves on the proxy side. SOCKS5 vs HTTP proxies covers when each is the better pick.

Browsers and DNS Leaks

  • Chrome with an HTTP proxy resolves hostnames on the proxy. With a SOCKS5 proxy set via --proxy-server=socks5://host:port, Chrome also sends hostnames to the proxy.
  • Firefox has a specific setting for SOCKS: tick "Proxy DNS when using SOCKS v5" in the connection settings (network.proxy.socks_remote_dns in about:config). Without it, Firefox resolves locally.
  • Browser DNS-over-HTTPS can bypass a SOCKS setup in some configurations. If you rely on SOCKS, test after enabling it.
  • WebRTC is a separate leak: it can reveal your local and public IPs to page scripts regardless of DNS. Use a browser profile that disables or proxies WebRTC for sensitive work.

Our guides to setting up a proxy in Chrome and Firefox proxy setup walk through these settings.

How to Test for a DNS Leak

From the command line, the reliable test is to watch DNS traffic leave your machine while you make a request through the proxy:

# Terminal 1: watch outgoing DNS queries (macOS/Linux)
sudo tcpdump -n -i any port 53

# Terminal 2: make a request through the proxy to a name you haven't visited
curl -s -x socks5h://USERNAME:[email protected]:1080 https://example.org -o /dev/null

With socks5h, tcpdump shows no query for example.org. Change the scheme to socks5 and run it again: you'll see the query go out to your local resolver. In a browser, a DNS leak test page lists the resolvers that looked up its unique test domains. If those resolvers belong to your ISP rather than a network near the proxy's country, you're leaking.

Other Places DNS Leaks Hide

  • Libraries that pre-resolve hostnames to apply connection pools or IP filters before using the proxy.
  • Scripts that call socket.gethostbyname() or similar themselves, for logging or validation.
  • Containers with their own DNS settings; see our Docker proxy settings guide.
  • Health checks or monitoring that hit the target directly rather than through the proxy.

Leak-Free Proxies With NodeProxies

NodeProxies supports both HTTP (global.nodeproxies.xyz:8080) and SOCKS5 (port 1080). Use HTTP, or socks5h:// for SOCKS, and lookups happen on the proxy side, near the exit in the country you targeted with -country-xx. Sign up and test with a 100 MB plan, or check pricing.

FAQ

What is the difference between socks5 and socks5h?

With socks5:// the client resolves hostnames itself and sends the proxy an IP address. With socks5h:// it sends the hostname and the proxy resolves it, so no DNS query leaves your machine.

Do HTTP proxies leak DNS?

Not normally. The client sends the hostname to the proxy, which does the lookup. Leaks only occur if your code resolves the name separately.

Does a DNS leak reveal my IP to the website?

Not directly. The website sees the proxy's IP, but the DNS query reveals your resolver, often your ISP, and can steer you to the wrong regional server.

How do I enable remote DNS in Firefox?

In Settings, Network Settings, choose manual proxy configuration with SOCKS v5 and tick "Proxy DNS when using SOCKS v5".

NodeProxies

Ready to get started?

90M+ residential, mobile & datacenter proxies. Datacenter from $0.30/GB, residential from $0.42/GB. No contracts.

Create free account