Back to all posts
SOCKS5 Remote DNS vs Local DNS: A Practical Test

SOCKS5 Remote DNS vs Local DNS: A Practical Test

November 21, 2026

Most proxy failures that look like network errors are DNS decisions in disguise. With an HTTP proxy, your client usually sends a hostname and lets the proxy resolve it. SOCKS5 is different: it lets the client choose whether DNS happens locally or at the proxy. That choice changes leaks, geo behavior, split-horizon resolution, and which hostnames work at all. This post shows how to identify the mode your client uses and test both paths with curl and Python.

Why SOCKS5 has two DNS modes

A SOCKS5 request can carry an IPv4 address, an IPv6 address, or a domain name. The address type is the switch:

  • Local DNS: the client resolves the hostname first and sends an IP address to the proxy. The proxy connects to that IP.
  • Remote DNS: the client sends the hostname to the proxy. The proxy resolves it and connects.

HTTP proxies behave mostly like remote DNS. For HTTPS, the client sends CONNECT host:443; for plain HTTP, the request line contains the absolute URL with the hostname. The proxy resolves the name. SOCKS5 exposes both modes, so client configuration matters.

When local DNS is acceptable

Local DNS is fine when the target is public and your resolver returns the same address the proxy would use. It is also useful when you need a local override from /etc/hosts, or when the proxy cannot resolve an internal name but your machine can.

When remote DNS matters

Remote DNS is usually the better default for public, geo-sensitive traffic. The proxy resolves the name from its own network, so CDN and geo logic see the proxy location rather than your laptop location. It also avoids sending DNS queries for target hostnames to your local resolver. The tradeoff is that internal or split-horizon names may fail because the proxy cannot resolve them.

Test the two modes with curl

curl has separate flags for each mode. --socks5 resolves locally. --socks5-hostname sends the hostname to the proxy.

curl -sS --socks5 GATEWAY_HOST:SOCKS5_PORT \
  -U USERNAME:PASSWORD \
  https://api.ipify.org?format=json

curl -sS --socks5-hostname GATEWAY_HOST:SOCKS5_PORT \
  -U USERNAME:PASSWORD \
  https://api.ipify.org?format=json

Both should return an exit IP if the proxy works. To see the SOCKS5 negotiation, add -v. You will see the request granted message and the address type in the debug output. If one mode fails and the other succeeds, you have found a DNS-mode problem, not a dead proxy.

A deterministic hosts-file test

Exit IP alone does not prove which resolver was used. You can force the difference with a temporary hosts entry. Add a public hostname to your local hosts file and point it at loopback:

sudo sh -c 'printf "127.0.0.1 api.ipify.org\n" >> /etc/hosts'

Now run both curl commands. With --socks5, curl resolves api.ipify.org locally to 127.0.0.1 and asks the proxy to connect to loopback. That usually fails or reaches the wrong service. With --socks5-hostname, curl sends the hostname, the proxy ignores your hosts file, and the request succeeds. Remove the line you added when you are done.

This test is blunt but reliable. It shows that local DNS mode trusts your machine, including local overrides, while remote DNS mode trusts the proxy resolver.

Test the two modes in Python

With requests, the proxy URL scheme selects the DNS mode. Use socks5:// for local DNS and socks5h:// for remote DNS. Install the SOCKS extra first:

pip install 'requests[socks]'

Then compare both paths:

import requests

LOCAL = 'socks5://USERNAME:PASSWORD@GATEWAY_HOST:SOCKS5_PORT'
REMOTE = 'socks5h://USERNAME:PASSWORD@GATEWAY_HOST:SOCKS5_PORT'

for label, proxy in [('local', LOCAL), ('remote', REMOTE)]:
    try:
        response = requests.get(
            'https://api.ipify.org?format=json',
            proxies={'http': proxy, 'https': proxy},
            timeout=15,
        )
        print(label, response.status_code, response.text)
    except requests.RequestException as exc:
        print(label, type(exc).__name__, exc)

Run it once normally, then again with the temporary hosts override from the previous section. The local mode should break or return a different result; the remote mode should keep working. That is the behavior you want to document for your scraper or automation job.

Confirm with DNS capture

If you need stronger evidence, watch DNS traffic while the request runs. On Linux, tcpdump -i any udp port 53 will show local queries. In local DNS mode you should see a query for the target hostname from your machine. In remote DNS mode you should not see that query, because the hostname goes inside the SOCKS5 request. This is also a practical way to catch accidental DNS leaks in a new client library.

Common failure patterns

  • General SOCKS server failure often means the proxy could not resolve the hostname in remote DNS mode, or refused the connection.
  • Host unreachable can happen when local DNS sends a private or loopback address that makes no sense from the proxy network.
  • Geo mismatch is common when local DNS resolves a CDN name to a nearby edge, then the proxy connects to that edge. Remote DNS lets the proxy resolver pick the edge it would normally use.
  • Internal names fail under remote DNS because the proxy has no route to your private DNS zone. Use local DNS or an HTTP proxy path for those targets.

Configure the proxy for this test

If you use RoProxy, each proxy connects through GATEWAY_HOST on HTTP_PORT, and proxies on the Pro and Business plans also provide a SOCKS5_PORT. Build the URL with the placeholders and keep the mode explicit:

export SOCKS5_REMOTE='socks5h://USERNAME:PASSWORD@GATEWAY_HOST:SOCKS5_PORT'
curl -sS --socks5-hostname GATEWAY_HOST:SOCKS5_PORT \
  -U USERNAME:PASSWORD \
  https://httpbin.org/ip

Do not rely on a library default. Many clients silently choose local DNS for socks5:// and remote DNS only for socks5h://. Write the scheme you mean in configuration, and assert it in a small test.

A short checklist

  1. Know your client default: curl, requests, and browser stacks do not all behave the same.
  2. Prefer remote DNS for public, geo-sensitive traffic and for avoiding local resolver exposure.
  3. Prefer local DNS when you need hosts-file overrides or private names.
  4. Verify the exit IP with https://api.ipify.org?format=json or https://httpbin.org/ip.
  5. Capture DNS traffic when the result is ambiguous.
  6. Log the DNS mode next to the proxy URL so failures are diagnosable later.

DNS mode is not a minor implementation detail. It decides which resolver sees the hostname, which network chooses the destination IP, and whether local overrides apply. Test it once, encode it in your client setup, and you will spend less time debugging phantom proxy failures. RoProxy's SOCKS5 port on the Pro and Business plans gives you a direct way to run the same local-versus-remote test against the proxy you use in production.