Try 25 MB of US mobile proxy data free for 30 days.Start free trial
December 1, 202611 min read

SOCKS5 DNS Resolve: Local vs Remote Lookups Explained

Two paths showing alternative DNS lookup locations

With SOCKS5, the client decides who resolves the hostname. If it sends the proxy a domain name, the proxy does the DNS lookup. If it sends an IP address, your own machine already did it. For geo-targeted scraping, price comparison and ad verification, that choice decides which resolver sees your targets and which region's answer you get back. At Masklabs we run US mobile proxies on real carrier IPs in 46 cities, and the setting below is one of the first things we check when a geo-targeted job returns odd results.

TL;DR

  • SOCKS5 lets the client send a destination as an IPv4 address, an IPv6 address or a domain name. A domain name means the proxy resolves it.
  • In curl, socks5:// resolves locally and socks5h:// resolves on the proxy side. The h stands for hostname.
  • For geo-targeted data collection, proxy-side resolution keeps lookups near the exit IP and keeps your resolver from seeing your target list.
  • Browsers, PAC scripts and bypass rules can still trigger local lookups, so verify with a verbose trace or a packet capture instead of assuming.
  • Remote resolution is not encryption: the proxy and anyone watching the plain SOCKS5 exchange can still see the hostname.

Table of Contents

What DNS resolution means in a SOCKS5 connection

DNS resolution turns a name such as example.com into an IP address your client can connect to. With a direct connection, your operating system or application asks a DNS resolver, usually your ISP's, your router's or a public service.

With a proxy in the middle, there are two possible places for that lookup. Your machine can resolve the name and tell the proxy "connect to this IP." Or your machine can hand the proxy the name and let it resolve and connect.

Local and remote DNS lookup paths compared

SOCKS5 supports both. RFC 1928, the protocol specification, defines three address types in a CONNECT request: 0x01 for IPv4, 0x04 for IPv6 and 0x03 for a fully qualified domain name, sent as a length byte followed by the name. The protocol does not force a choice. Your client library does, and its default is not always what you expect.

The same specification lists reply codes you will meet when a lookup goes wrong, including 0x01 (general SOCKS server failure), 0x04 (host unreachable) and 0x08 (address type not supported). Keep those in mind for the troubleshooting section.

Local vs remote resolution: what changes for your data

The difference is easiest to see side by side.

Local resolution (client resolves)Remote resolution (proxy resolves)
What the client sendsIP address (ATYP 0x01 or 0x04)Domain name (ATYP 0x03)
Who sees the target hostname in DNSYour resolverThe resolver the proxy uses
Whose geography shapes the answerYoursThe proxy's exit location
Local hosts file or DNS filteringAppliesIgnored
curl schemesocks5://socks5h://

For the audience this article is written for, three consequences matter most.

Geo-accurate answers. Many sites and CDNs return different IPs depending on where the DNS query comes from. If your laptop in Frankfurt resolves a retailer's hostname and the proxy then connects to that address from a Chicago carrier IP, you may land on an edge server chosen for Frankfurt. When the proxy resolves the name, the lookup happens on the exit side, so the answer matches the location you are trying to measure. A price check or local search test then reflects what a shopper in that city actually receives.

Privacy of your target list. With local resolution, your resolver logs every hostname you scrape. The Tor Project describes this as the stickiest issue in supporting SOCKS clients: if the client does its own lookup, the DNS server learns which addresses the client wants to reach. That is why Tor added a dedicated RESOLVE command for remote lookups.

Fewer local surprises. A local hosts file, a corporate DNS filter or a split-horizon setup only affects local resolution. Remote resolution bypasses all of them, which is usually what you want for scraping and sometimes the cause of "works on my machine" confusion.

One caveat keeps the picture honest. Even a perfect remote-resolution setup needs your machine to find the proxy gateway itself. If the gateway is a hostname, that one lookup is local. Entering the gateway as an IP address removes it.

How to set it in curl

curl is the quickest way to see the behavior, and the same scheme convention appears in many other tools.

  • --socks5 or a socks5:// proxy URL: the curl documentation says it resolves the hostname locally, and assumes port 1080 if you give none.
  • --socks5-hostname or socks5h://: the proxy resolves the name.

The everything curl reference lays out the full table: SOCKS4 and SOCKS5 resolve in curl, while SOCKS4a and SOCKS5h let the proxy resolve. SOCKS5h also supports IPv6 destinations.

A minimal check looks like this:

curl -v --proxy socks5h://USER:[email protected]:1080 https://example.com/

In the verbose output, the connect line tells you the mode. A local-mode run prints a resolved IP address, and a remote-mode run prints the hostname itself. We keep a set of ready-to-paste commands in our guide to curl proxy commands for debugging DNS.

Python and other scraping stacks

Most HTTP libraries follow the same naming idea: one scheme that resolves locally, one with an h that sends the hostname to the proxy. In Python Requests the socks5h:// scheme is the one that hands names to the proxy, and our walkthrough on using a SOCKS5 proxy with Python Requests shows the setup. If you use the async client, the HTTPX proxy guide covers the same options with proxy= and mounts. Go and PHP have their own conventions, covered in our Go scraping and PHP cURL guides.

Whatever the stack, do not trust the default. Read the library's documentation for the exact scheme, then confirm with a trace.

Browsers and browser automation

Browsers behave a little differently from curl. Chromium's design documentation on SOCKS proxies states that with --proxy-server="socks5://myproxy:8080", Chrome resolves the URL hostname on the proxy server rather than locally. The same page warns that Chrome's DNS prefetcher can still issue local DNS requests unless you disable it. As a catch-all, it suggests the flag --host-resolver-rules="MAP * ~NOTFOUND , EXCLUDE myproxy", which blocks local lookups for everything except the proxy host.

That matters for Playwright, Puppeteer and Selenium jobs, where the browser is launched with these same flags. If your automation measures local search results or ad placements, a stray local lookup is the kind of thing that skews a comparison between cities without any error message. Our Chrome proxy flags guide goes through --proxy-server and the flags around it.

The Pydoll documentation adds a useful nuance: Chrome hands hostnames to the proxy for any proxy type, and the real difference between types is what the proxy can see, not who resolves DNS. So test your actual browser build rather than relying on a rule of thumb.

Browsers and browser automation

Where local lookups still sneak in

Even when the scheme is right, some paths resolve names on your machine:

  1. Proxy auto-config (PAC) scripts. Functions such as dnsResolve and isResolvable run client-side before any proxy connection, according to Byteful's DNS guide.
  2. Bypass rules. Domains excluded from the proxy are resolved locally by definition.
  3. Prefetching. Chrome's prefetcher, as noted above.
  4. The gateway hostname. One local lookup for the proxy endpoint itself.
  5. Other processes. An environment variable set for one child process does not cover another app, and a leak test in one browser profile does not certify a Python script.

There is also a transport point worth stating plainly. Remote resolution changes who looks up the name. It does not encrypt the connection to the proxy, so the hostname can still be visible to someone watching the network path between you and the gateway. Treat it as one control among several, alongside protected transport and good credential handling. Our guide to SOCKS5 authentication methods covers the credential side.

DNS hygiene also reaches beyond leaks. If your team owns domains for dashboards or callbacks, domain hijacking protection is part of keeping the DNS side of your infrastructure trustworthy.

How to verify which mode your client uses

Nothing in an HTTP response tells you which resolver was used, so you have to look at the client or the wire. Four checks, from fastest to most thorough:

  1. Read the verbose trace. With curl 8.7.1, proxylane's write-up shows socks5 printing a connect line with a resolved IP and marked as locally resolved, while socks5h printed the hostname and marked it as remotely resolved. Run curl -v against your own endpoint and compare.
  2. Use a hosts-file trap. Add 127.0.0.1 example.test-style entry for a hostname you can reach, then request it through the proxy. If the request goes to loopback or fails, your client resolved locally. If it succeeds, the proxy resolved it. This is deterministic and takes a minute.
  3. Capture port 53. Run tcpdump -i any port 53 while your job runs. Queries for your target domains appearing on your machine mean local resolution. Expect to see the gateway lookup unless you use its IP.
  4. Use the client's own guard rails. The Tor Project's leak-check guide describes a setup that logs warnings when an application leaks DNS and can refuse such connections. The idea carries over to your own tooling: fail loudly on local resolution instead of discovering it in the data.

Run the check for each tool in the pipeline, not once for the project. A scraper, a headless browser and a monitoring script can each behave differently. We cover the wider decision between proxy types, including five DNS leak tests, in our article on SOCKS5 vs HTTP proxy for engineers.

Troubleshooting resolution failures

Match the symptom to the cause:

  • Works with socks5://, fails with socks5h://. The proxy side cannot resolve the name, or returns a server failure. Check the destination spelling, then try the same name from another exit.
  • Wrong content or wrong region with local mode. The answer you resolved locally may point at an edge server for your location. Switch to remote resolution and compare.
  • Connects to a private or loopback address. A local hosts file or internal DNS override took effect. Remote mode ignores both.
  • Cannot resolve the proxy host itself. Check the endpoint spelling and your bootstrap DNS. This is a different failure from a proxy authentication error, and the error text usually shows which one you have.
  • Reply code 0x08. The address type was not supported, per RFC 1928. Some tools send IPv6 or a domain name in a form the server does not accept, so check the scheme and protocol version.

Remember also that the DNS mode selects the resolver, not the exit country. The exit location comes from the IP the proxy connects from.

Perspective

Most DNS problems we see described by data teams are really scheme problems: one character, the h, in a proxy URL. We think the right default for geo-targeted collection is to let the proxy resolve the name, because the whole point of picking a city is to see the web the way that city sees it.

Our network is built on real US carrier IPs in 46 cities, with sticky and rotating sessions and HTTP, HTTPS and SOCKS5 support. That combination only pays off when the lookup and the connection come from the same place. A realistic carrier IP paired with a resolver answer from another continent undercuts the accuracy you are paying for.

So our advice is simple. Set remote resolution deliberately, verify it per tool with a verbose trace, and keep it in your test suite so a library upgrade cannot change it silently.

Jon

Run it on real carrier IPs

If you are building scrapers, price monitors or ad verification jobs that depend on what a specific US city sees, Masklabs gives you SOCKS5, HTTP and HTTPS access over real mobile carrier IPs, with city-level targeting, rotating or sticky sessions, API access and metered per-byte billing. Plans on our pricing page start at $30.00 per month for Starter, with Basic at $100.00, Advanced at $500.00 and Scale at $1,000.00 per month, and there is a free trial with limited data so you can run the checks above on your own stack.

Masklabs

See the features and integrations for Python, Node.js, Java, C#, Rust and browser automation setups.

FAQ

What is the difference between socks5 and socks5h?

With socks5://, the client resolves the hostname locally and sends the proxy an IP address. With socks5h://, the client sends the hostname and the proxy resolves it. The curl documentation describes the first as resolving the hostname locally and the second as its separate proxy-side option.

Does SOCKS5 resolve DNS through the proxy by default?

Not necessarily. The protocol allows both, and the client decides. Chrome's documentation says it resolves on the proxy server with a socks5:// proxy, while curl does the opposite with the same scheme. Check the documentation of each tool and confirm with a trace.

Does remote DNS resolution make my traffic anonymous?

No. The proxy receives the hostname, so it can see where you are going. Remote resolution also does not encrypt the exchange between you and the proxy. It keeps your local resolver out of the picture and aligns lookups with the exit location.

Can I stop Chrome from making local DNS requests with a SOCKS5 proxy?

Mostly, yes. Use a socks5:// proxy server flag, disable DNS prefetching and add the host-resolver rule from Chromium's documentation that maps all names to not-found except the proxy host. Then check port 53 traffic to confirm.

Sources

Recommended