Proxy DNS Leaks: How to Check and Prevent Them
A proxy can hide your IP while your DNS lookups still leave through your own network. Learn how socks5 and socks5h differ, how browsers and tools handle DNS, and how to test a mobile proxy setup for DNS leaks.
Before any connection to a website starts, something has to turn its hostname into an IP address. That step is a DNS lookup. When you use a proxy, the lookup can happen in one of two places: on your own device, or on the proxy.
If it happens on your device, the request goes to your own DNS resolver, often the one run by your home or office internet provider, even though the website traffic itself goes through the proxy. When your setup is meant to keep DNS resolution on the proxy side but the lookup leaves through your local network instead, this is commonly called a DNS leak. Your traffic still reaches the website from the proxy IP, but the lookups show which domains you visit, and from which network.
This guide explains where DNS lookups happen with HTTP, SOCKS5, and OpenVPN connections, what a leak reveals, how common tools behave, and how to check a mobile proxy setup for DNS leaks.
What a DNS Leak Is
Where the lookup happens
A DNS lookup goes from a client to a recursive resolver, which finds the answer by asking the authoritative name servers for the domain. With a proxy, the important question is which resolver gets asked. If the proxy receives the hostname, the proxy side resolves it, and the lookup comes from the proxy's network. If your device resolves the hostname first and hands the proxy only an IP address, the lookup has already gone out through your own network. When the goal is to keep DNS on the proxy side, that second case is a DNS leak.
What a leak reveals
A leak does not expose the content of your traffic, and the website still sees the proxy IP on the connection. It exposes other things:
Suppose your mobile proxy exits on a Dutch carrier in Amsterdam, but your script uses client-side resolution. The website sees a Dutch mobile IP, while the DNS lookups for its hostnames come from your own resolver, possibly in another country.
A side effect on routing
Some content delivery networks decide which server to return in a DNS answer based on the location of the resolver that asked, or on the client subnet passed through EDNS Client Subnet. A 2015 SIGCOMM paper on end-user mapping describes how "traditional mapping systems identify a client using the IP of its name server." When the lookup happens on your device, the proxy may be sent to a server chosen for your location instead of the proxy's, which can add latency.
How Each Proxy Type Handles DNS
HTTP and HTTPS proxies
With an HTTP proxy, the client normally sends the hostname, not an IP address. For https:// URLs, it opens a tunnel with the CONNECT method, and HTTP/1.1 (RFC 9112) requires the client to "send only the host and port of the tunnel destination," for example CONNECT www.example.com:443. For plain http:// URLs, the client sends the full URL to the proxy. In this standard HTTP proxy flow, the proxy resolves the destination hostname. Chromium's proxy documentation states that "when using an HTTP proxy in Chrome, name resolution is always deferred to the proxy." A leak is still possible if a tool resolves the name itself and passes an IP address to the proxy, so it is worth checking.
SOCKS5: socks5 vs socks5h
SOCKS5 supports both behaviors. RFC 1928 lets the client send the destination as an IPv4 address, an IPv6 address, or a domain name, in which case "the address field contains a fully-qualified domain name" and the proxy, which receives the name, resolves it. Which one a client sends depends on the client and its settings. In many tools, the proxy URL scheme decides it: socks5:// resolves on your device, and socks5h:// sends the hostname to the proxy. The libcurl documentation describes socks5h:// as "SOCKS5 Proxy. Proxy resolves URL hostname," and urllib3, which Python Requests uses for SOCKS, recommends "socks5h:// or socks4a:// schemes" so that DNS resolution happens on the proxy side.
Browsers handle this without a URL scheme. Chromium's documentation says that with a SOCKS5 proxy, "name resolution is always done proxy side," and that Chrome has no option to change this. Chrome also does not support authentication for SOCKS5 proxies, so if your proxy uses a username and password, use its HTTP endpoint in Chrome, which also leaves DNS to the proxy. In Firefox, the setting is the "Proxy DNS when using SOCKS v5" checkbox. Firefox 128 turned it on by default for SOCKS5, according to Mozilla's bug tracker, while SOCKS4 keeps local resolution by default.
The table below summarizes the defaults:
| Tool | Resolves on your device | Lets the proxy resolve |
|---|---|---|
| curl | socks5:// or --socks5 |
socks5h:// or --socks5-hostname; HTTP proxies receive the hostname |
| Python Requests (urllib3) | socks5:// |
socks5h://; HTTP proxies receive the hostname |
| Chrome and Chromium | SOCKS4 always; not used with HTTP or SOCKS5 proxies | Always, for HTTP and SOCKS5 proxies |
| Firefox | SOCKS4 by default; SOCKS5 if "Proxy DNS when using SOCKS v5" is turned off | SOCKS5 by default since Firefox 128 |
OpenVPN
An OpenVPN connection works at the system level instead of per application, so DNS depends on which resolver the system uses while the tunnel is up. The server can push DNS servers to the client, but whether the client applies them depends on the platform. OpenVPN's community wiki notes that on Linux an external script has been needed to apply pushed DNS servers, so check how your client version handles DNS. On Windows, OpenVPN offers the --block-outside-dns option, which the wiki recommends "to prevent DNS leaks at the client."
Apps outside the proxy
A proxy only covers the applications configured to use it. Other apps on the same device keep using your normal network and resolver. Mobile Proxy vs VPN compares the two approaches.
What We Saw in a Local Test
To check these defaults, we ran a small test on a Linux machine. A local SOCKS5 server and a local HTTP proxy logged the destination each client asked for, then refused the connection. The test hostname, shop.example.test, resolved to 127.0.0.1 through the machine's hosts file, so a client that resolved it locally would send 127.0.0.1. For Chromium, we used a hostname that does not exist, no-such-host-abc123.invalid. Because that name cannot be resolved anywhere, a hostname arriving at the proxy shows that the browser did not need to resolve it first.
These were the results:
| Client and proxy setting | What the proxy received |
|---|---|
curl 8.5.0, socks5:// or --socks5 |
The IP address 127.0.0.1, already resolved on the device |
curl 8.5.0, socks5h:// or --socks5-hostname |
The hostname shop.example.test |
| curl 8.5.0, HTTP proxy, https:// URL | CONNECT shop.example.test:443 |
| curl 8.5.0, HTTP proxy, http:// URL | GET http://shop.example.test/page |
Python Requests 2.33.1, socks5:// |
The IP address 127.0.0.1 |
Python Requests 2.33.1, socks5h:// |
The hostname shop.example.test |
| Python Requests 2.33.1, HTTP proxy | CONNECT shop.example.test:443 |
| Chromium 141, SOCKS5 proxy | The hostname no-such-host-abc123.invalid |
| Chromium 141, HTTP proxy | CONNECT no-such-host-abc123.invalid:443 |
The pattern matches the documentation: socks5:// resolved on the device, while socks5h://, HTTP proxies, and Chromium sent the hostname to the proxy.
How to Check Your Setup for DNS Leaks
Check the proxy setting in your scripts
In code, look at the proxy URL. With Python Requests, SOCKS support needs the requests[socks] extra, and the h in socks5h decides where hostnames are resolved:
import requests
# socks5h: the proxy resolves hostnames. socks5 would resolve them on your device.
PROXY = "socks5h://user:pass@proxy-endpoint:1080"
PROXIES = {"http": PROXY, "https": PROXY}
response = requests.get(
"https://api.ipify.org",
params={"format": "json"},
proxies=PROXIES,
timeout=15,
)
response.raise_for_status()
print("Exit IP:", response.json()["ip"])
With curl, the verbose output shows where the name was resolved. In our test with curl 8.5.0, running curl -v with socks5h:// printed "SOCKS5 connect to shop.example.test:443 (remotely resolved)", while socks5:// printed "(locally resolved)".
Run a DNS leak test in the browser
DNS leak test sites make your browser load hostnames that have never existed, so no cache can answer them and the lookup has to reach the name servers the test controls. The test then lists the resolvers that asked. Open a leak test, such as browserleaks.com/dns, in the browser profile that uses the proxy. The resolvers listed should belong to the proxy side. If your own internet provider or office network appears, lookups are leaving outside the proxy. A large public resolver in the list is not a leak by itself, but it should be one the proxy side uses, not one your device uses directly.
Compare the results with the exit IP
Check the exit IP of the same profile or script, as described in How to Test a Mobile Proxy. For a Dutch mobile proxy, the exit IP should belong to a Dutch carrier, and the resolvers should not point to your home network. Dutch Mobile Carrier IPs: KPN, Odido and Vodafone Explained shows how to identify the carrier behind an exit IP.
How to Prevent DNS Leaks
socks5h:// instead of socks5:// in scripts and tools, or --socks5-hostname in curl. If you have to use SOCKS4, use socks4a://.--block-outside-dns, and make sure the pushed DNS servers are applied on other platforms.FAQ
Does a DNS leak reveal my IP address to the website?
Not directly. The website still sees the proxy IP on the connection. A leak reveals your resolver, and resolvers that use EDNS Client Subnet can pass on part of your IP address to the name servers that answer the lookup.
Is socks5h a different protocol from SOCKS5?
No. Both use SOCKS5. The h tells the client to send the hostname to the proxy instead of resolving it first.
Does HTTPS prevent DNS leaks?
No. HTTPS protects the connection to the website, but the DNS lookup for the hostname is a separate request that happens before that connection.
Can Chrome leak DNS when a proxy is set?
For requests that go through an HTTP or SOCKS5 proxy, Chrome leaves name resolution to the proxy. Other applications on the same device are not covered by Chrome's proxy setting.
Is a WebRTC leak the same as a DNS leak?
No. WebRTC can expose IP addresses through the browser, which is a separate issue from DNS lookups. Mobile Proxies for Antidetect Browsers explains how to check WebRTC.
Platform terms of service still apply. Keeping DNS on the proxy side changes how your traffic looks to the network. It does not authorize activity that a platform prohibits.
Related Reading
Dedicated 4G and 5G Mobile Proxies with HTTP, SOCKS5 and OpenVPN
PowerProxy provides dedicated mobile connections on real carrier SIMs, with HTTP, SOCKS5, and OpenVPN support. In Amsterdam, PowerProxy offers Odido, KPN, and Vodafone SIMs.
No credit card required · 4.3 / 5 on Trustpilot ★★★★★ · 1,200+ businesses
Narmin Kamilsoy
Contributing author sharing insights and stories on our blog.