How to Diagnose and Prevent a Proxy DNS Leak
By the ProxyV4 Engineering Team · Updated:
A proxy DNS leak happens when an app sends its traffic through a proxy but still looks up hostnames with your local DNS resolver. Websites see the proxy's IP, while your router, ISP or DNS provider still sees every hostname you visit. The usual fix is remote DNS: use socks5h:// (or the app's "proxy DNS" option) so the proxy resolves names for you.
What is a proxy DNS leak and why does it happen?
Before connecting to a site, something has to turn its hostname into an IP address. Without a proxy, your operating system asks the resolver set by your router or ISP. With a proxy, the app can either do that lookup itself and give the proxy an IP address, or hand the hostname to the proxy and let it resolve the name.
If the app resolves locally, the connection still goes through the proxy, but the lookup does not. Your local network and DNS provider see the hostnames, and DNS-based tests and services see a resolver near you rather than near the proxy, which can also make location look inconsistent.
Whether this happens is decided by the app and its proxy setting, not by the proxy server. That is why the same proxy can leak in one tool and not in another.
When lookups stay local: HTTP, SOCKS4 and SOCKS5
The protocol decides whether the client can pass a hostname to the proxy at all.
With an HTTP proxy, mainstream clients send the hostname: plain HTTP requests carry the full URL, and HTTPS uses CONNECT example.com:443, so the proxy does the lookup. Leaks with HTTP proxies come from parts of an app that make their own lookups outside the proxied request, such as browser DNS prefetching.
SOCKS4 vs SOCKS4a and SOCKS5
SOCKS4 only carries an IPv4 address, so the client must resolve the name locally. SOCKS4a added a way to pass the hostname instead.
SOCKS5 (RFC 1928) lets the client send an IPv4 address, an IPv6 address or a domain name. If the client sends the domain name, the proxy resolves it; if the client resolves first and sends the IP, the lookup has leaked.
Why socks5h remote DNS prevents leaks
In curl and in Python libraries built on urllib3, the scheme chooses the behavior. socks5:// resolves the hostname locally and sends the IP; socks5h:// sends the hostname so the proxy resolves it.
With socks5h:// the lookup happens on the proxy's network, so both the DNS query and the connection come from the proxy side.
How to run a DNS leak test with your proxy
An ordinary what-is-my-IP page only shows the IP your HTTP connection came from; it cannot see which resolver looked up the name.
A DNS leak test makes your client look up unique, random subnames on a domain it controls. Its nameserver records which resolver asked, and the page shows those resolvers. Through a proxy with remote DNS, they should belong to the proxy's side, not to your ISP or router.
- Exit IP. Open the my IP tool through the proxy and confirm it shows the proxy's IP.
- Resolvers. Run a DNS leak test in the same browser or profile. Your ISP's or your own DNS provider's resolvers in the list mean lookups are leaving locally.
- WebRTC. WebRTC is a separate leak path: a browser can reveal local or public addresses through it without any DNS lookup. Check with the WebRTC leak test.
- Scripts. For code, capture traffic on your network interface on port 53 (for example
sudo tcpdump -ni any port 53) while the script runs. Lookups for the target hostname mean local resolution. Encrypted DNS on port 443 or 853 will not show up there.
Fixing leaks across browsers, tools, and scripts
The fix lives in each app's proxy settings, so check every tool you route through the proxy.
Firefox and Chrome
In Firefox's Network Settings, with a SOCKS v5 proxy set, tick "Proxy DNS when using SOCKS v5" (labels vary by version; the long-standing preference is network.proxy.socks_remote_dns in about:config). Recent versions turn it on by default for SOCKS5, but check it. Proxy extensions can handle DNS differently from the built-in setting, so test again after installing one. The Firefox proxy setup guide walks through the dialog.
If Firefox uses DNS over HTTPS, lookups go to the DoH provider rather than through the proxy. Turn DoH off for that profile or accept that the DoH provider sees the names.
Chrome resolves hostnames on the proxy for SOCKS5 set with --proxy-server, but Chromium's documentation notes that other parts of the browser, notably the DNS prefetcher, can still resolve locally. It suggests --host-resolver-rules="MAP * ~NOTFOUND , EXCLUDE myproxy" as a catch-all, where myproxy is your proxy's host.
Using socks5h in cURL, Python, and CLI utilities
In curl, --socks5 resolves locally, while --socks5-hostname or the socks5h:// scheme resolves on the proxy:
curl --max-time 20 -x socks5h://USER:PASS@IP:PORT https://proxyv4.com/api/my-ipIn Python requests, install SOCKS support with pip install "requests[socks]" and use socks5h:// in the proxies dictionary:
import requests
proxy = "socks5h://USER:PASS@IP:PORT"
proxies = {"http": proxy, "https": proxy}
response = requests.get("https://proxyv4.com/api/my-ip", proxies=proxies, timeout=15)
print(response.text)With socks5:// instead, urllib3 resolves the hostname with your system resolver before opening the SOCKS connection. Without the extra package, requests raises InvalidSchema: Missing dependencies for SOCKS support.
Where a ProxyV4 SOCKS5 proxy fits
Remote DNS needs a proxy that accepts SOCKS5 with a hostname, which every ProxyV4 proxy does, alongside HTTP(S), with username and password. On the order's page you choose HTTP only, SOCKS5 only, or both on the same port; switching modes can move the proxy to a new port, so copy the line again afterwards.
Private datacenter IPv4 is available in the United States, Vietnam, Japan, South Korea, Singapore, the United Kingdom and Hong Kong, and static ISP proxies, fixed IPs registered to consumer internet providers, in 23 countries. Each has one tenant per IP for the whole term, the IP stays the same when you renew before expiry, and traffic is never metered or billed.
It does not fit if you need per-request rotation (rotating proxies are waitlist-only) or mobile IPs. IPv6 proxies are a separate product that only works on IPv6-ready sites; private IPv4 works on every IPv4 and dual-stack site. If you route UDP-based tools, ask support through a ticket before ordering. Buy one IP, run the leak tests above, then scale. See live prices.
Still leaking after switching to remote DNS?
- A tool still uses `socks5://`. Search configs, environment variables (
ALL_PROXY,HTTPS_PROXY) and extension settings for the scheme without theh. It is one of the most common causes in custom code. - IPv6 outside the proxy. If your machine has IPv6 and an app only sends IPv4 through the proxy, some lookups or connections can go out directly over IPv6. Check the app's settings, or test with IPv6 disabled on the adapter.
- Security software or a VPN client. Antivirus, endpoint filters and VPN clients can intercept DNS on port 53 or 853 and resolve locally regardless of browser settings.
- Encrypted DNS in the browser or OS. DoH or DNS over TLS sends lookups to that provider instead of through the proxy.
- System-wide vs app proxy. A system proxy setting is used only by apps that honor it; others connect and resolve directly.
Frequently asked questions
What is the difference between socks5 and socks5h?
socks5:// resolves the hostname on your machine and sends the IP to the proxy. socks5h:// sends the hostname and the proxy resolves it.
Does an HTTP proxy cause DNS leaks?
Usually not for the requests themselves: mainstream clients send the hostname to an HTTP proxy, including in CONNECT. Leaks come from parts of an app that resolve names on their own, such as browser DNS prefetching.
Can WebRTC leak my real IP even if DNS is not leaking?
Yes. WebRTC is separate from DNS and can expose addresses through the browser's peer-to-peer features. Check it with the WebRTC leak test.
Can I use SOCKS5 with remote DNS on ProxyV4 proxies?
Yes. Every ProxyV4 proxy supports SOCKS5 with username and password, so socks5h:// or a browser's proxy DNS option sends lookups to the proxy.
What is covered if my proxy has technical connection issues?
A proxy that fails for a technical reason, such as not connecting or showing the wrong location, is covered by the refund policy, credited to your account balance.
SOCKS5 with remote DNS keeps lookups on the proxy
Every ProxyV4 proxy supports HTTP(S) and SOCKS5 with username and password, so lookups can run on the proxy. Traffic on IPv4 and static ISP is never metered; test one IP first.
Get a working proxy