AI summary

With a SOCKS5 proxy at socks5://, your computer does the DNS lookup, so your ISP's DNS server sees each hostname. With socks5h:// or an HTTP proxy, the proxy does it.

A proxy is a server that opens connections for you. The site sees the proxy’s IP address, not yours.

But even with a proxy, someone else can still see which sites you visit. Whether they can comes down to one letter at the start of the proxy address: socks5:// or socks5h://.

I set up socks5://, socks5h:// and an HTTP proxy in a small Docker lab and ran each one. Every terminal output below comes from that lab, and you can run it yourself at the end.

First, the DNS lookup

Computers connect to IP addresses, not names.

A hostname is a machine’s name, like shop.example. Before connecting to it, your computer asks a DNS server: “what’s the IP address of shop.example?” That question is a DNS lookup.

This is also called resolving the hostname.

Normally that lookup goes to your ISP’s or your office network’s DNS server. That server sees every site you visit.

Three options, one difference

SOCKS5 and HTTP are two protocols a program can use to talk to a proxy. A proxy address can start in three ways. The difference is who does the DNS lookup:

  • socks5://: your computer does the DNS lookup. Only an IP goes to the proxy.
  • socks5h://: the proxy does the DNS lookup. The hostname goes to the proxy.
  • http://: like socks5h://. The proxy does the DNS lookup.

The h in socks5h stands for hostname.

So with socks5:// your DNS lookups still go to your ISP, even though you’re using a proxy. That’s called a DNS leak.

socks5:// · Kubernetes API over an SSH tunnel

Your company’s Kubernetes cluster isn’t open to the internet.

Only the company’s SSH entry server, the bastion, can reach its API.

Kubernetes’s own guide suggests this for the job: open a tunnel with ssh -D 1080, and set proxy-url: socks5://localhost:1080 in kubectl’s config.

ssh -D 1080 opens a SOCKS5 proxy on your laptop’s port 1080 that sends everything through the bastion.

kubectl sends that proxy a CONNECT request: the address and port it wants a connection to. SSH carries that address through the tunnel to the bastion, and the bastion opens the connection.

The API address in the config is an IP, so socks5:// is enough. There’s no hostname to resolve, and your DNS server never comes into it.

That changes once the address is a hostname.

The guide notes this too: with socks5h, the bastion resolves the hostname, so it never reaches your DNS server.

To the Kubernetes API through a tunnelThe API address in the config is an IP. Addresses from the lab.

socks5://

Your laptop already knows the API's IP. The tunnel carries that IP to the bastion. Your DNS is never asked.

  1. Your laptop → BastionAsks for 10.89.1.10:6443; SSH carries it through the tunnel
  2. Bastion → Kubernetes APIThe bastion passes the request to the API
  3. Kubernetes API → BastionThe answer comes back through the tunnel
The same setup in the labReal output. -x tells curl which proxy to use. I used curl instead of kubectl and left out options like -sS.
  1. curl --max-time 3 http://10.89.1.10:6443/versioncurl: (28) Connection timed out after 3002 milliseconds

    Without the tunnel the API can't be reached.

  2. curl -x socks5://127.0.0.1:1080 http://10.89.1.10:6443/versionAPI server (stand-in for the Kubernetes API). Request came from 10.89.1.2

    With an IP, socks5:// is enough. The API sees the request coming from the bastion.

  3. curl -x socks5://127.0.0.1:1080 http://k8s-api.internal:6443/versioncurl: (97) Could not resolve proxy: 127.0.0.1

    Only the bastion knows this hostname, so your laptop can't resolve it. curl's message is misleading: what it can't resolve isn't the proxy but k8s-api.internal.

  4. curl -x socks5h://127.0.0.1:1080 http://k8s-api.internal:6443/versionAPI server (stand-in for the Kubernetes API). Request came from 10.89.1.2

    With socks5h:// the bastion resolves the hostname.

socks5h:// · Collecting data from another country

Companies that track prices or collect data use proxy providers so their requests look like they come from another country.

One of the big providers, Bright Data, only accepts socks5h on its SOCKS5 service, as its docs say.

It refuses requests that send the target as an IP, because an IP means the client already resolved the hostname itself. Bright Data says it does this for compliance.

For collecting data from another country, you’d want socks5h:// anyway: many big sites answer DNS lookups with the server closest to whoever asks.

Say your price-tracking script runs in Turkey, and the proxy is in Germany. If the script resolves the hostname itself, your DNS server can give it the address of the server in Turkey, and you may end up with Turkey’s prices instead of Germany’s.

With socks5h:// the provider resolves the hostname, and the script talks to the server in Germany.

Through the provider's proxyAddresses from the lab; Turkey and Germany are the lab's example servers.

socks5h://

The hostname goes to the provider, which resolves it in Germany.

  1. Your script → ProviderCONNECT shop.example:80, as a hostname
  2. Provider → Provider's DNSWhat's the IP of shop.example?
  3. Provider's DNS → Provider10.90.0.22, the server in Germany
  4. Provider → shop.exampleGET /, to the server in Germany
A provider that only accepts hostnames, in the labReal output. I left out options like -sS.
  1. curl -x socks5://provider:1080 http://shop.example/curl: (97) cannot complete SOCKS5 connection to shop.example. (2)

    The provider refuses: the script resolved the hostname itself and sent an IP.

  2. curl -x socks5h://provider:1080 http://shop.example/shop.example, the server in Germany. Request came from 10.90.0.10

    The provider resolved the hostname, and the answer came from the server in Germany.

  3. cat /logs/proxy.logrefused 10.90.0.21:80 (an IP address: the client resolved the name itself)accepted shop.example:80 (a hostname, resolved here to 10.90.0.22)

    Both requests are in the provider's log. 10.90.0.21 is the server in Turkey, the address your DNS gave the script.

  4. grep -o 'query\[A\] shop.example.*' /logs/my-dns.logquery[A] shop.example from 10.90.0.100

    The only lookup your DNS server got came from the socks5:// attempt.

http:// · The company proxy

In many companies, computers can’t reach the internet directly; every request goes through the company proxy.

Developer tools document a setting for it, like npm’s proxy option or VS Code’s proxy support.

Most of these proxies are HTTP proxies like Squid.

The laptop doesn’t resolve the hostname. For a plain HTTP page it sends the proxy the whole address, like GET http://registry.example/.

For HTTPS the laptop wants an encrypted connection straight to the site, so the proxy can’t read the request. The laptop first sends CONNECT registry.npmjs.org:443, and the proxy opens a tunnel to that address: the same CONNECT idea, this time in HTTP.

Because the proxy resolves the hostname, the company can log which sites people visit and block the ones it doesn’t allow.

Through the company proxyAddresses from the lab; registry.example stands in for a package registry.

http://

Your laptop hands the whole address to the proxy. The proxy resolves the hostname and logs the request.

  1. Your laptop → SquidGET http://registry.example/
  2. Squid → Proxy's DNSWhat's the IP of registry.example?
  3. Proxy's DNS → Squid10.91.0.21
  4. Squid → registry.exampleGET /, and the request is logged
An office with Squid 6.13, in the labReal output. I left out options like -sS.
  1. curl http://registry.example/curl: (6) Could not resolve host: registry.example

    The laptop can't resolve the hostname itself.

  2. curl -x http://squid:3128 http://registry.example/registry.example, the package registry. Request came from 10.91.0.10

    The proxy resolved the hostname and let the request through.

  3. curl -o /dev/null -w %{http_code} -x http://squid:3128 http://games.example/403

    A blocked site: the proxy answers itself.

  4. cat /var/log/squid/access.log12/Nov/2026:21:32:17 +0000 10.91.0.100 TCP_MISS/200 GET http://registry.example/12/Nov/2026:21:32:17 +0000 10.91.0.100 TCP_DENIED/403 GET http://games.example/

    This one runs on the proxy, not the laptop. Both requests are in its log. TCP_MISS/200 is the one the proxy let through (MISS only means it wasn't served from Squid's cache). TCP_DENIED/403 is the blocked one.

What browsers and tools do

Browsers already protect you here. The places to watch are command-line tools and your own code.

  • Chrome and Edge: with a SOCKS5 proxy, the proxy always resolves the hostname. There’s no setting to change.
  • Firefox: since version 128 the proxy resolves the hostname by default. The “Proxy DNS when using SOCKS v5” option now comes switched on.
  • curl: socks5:// resolves the hostname on your computer. Use socks5h:// or --socks5-hostname.
  • Python’s requests: socks5:// resolves on your computer, socks5h:// on the proxy.
  • git: write git config http.proxy socks5h://.... git has known the difference since 2016; older versions treated socks5h:// like socks5://.
  • socks-proxy-agent in Node.js: socks5:// resolves on your computer, socks5h:// and plain socks:// on the proxy.
  • Tor: ordinary DNS can’t resolve .onion addresses; only Tor can. If you point curl or Python at Tor with socks5://127.0.0.1:9050 instead of socks5h://127.0.0.1:9050, a .onion page never opens.

Try it yourself

You can run all three jobs on your own computer with Docker.

Download the lab as a zip, unpack it and start the job you want:

bash
docker compose -f 1-ssh-tunnel.yml up -d --wait
docker compose -f 1-ssh-tunnel.yml exec client sh /lab/1-try.sh
docker compose -f 1-ssh-tunnel.yml down -v

For the other jobs, use 2-proxy-provider.yml with 2-try.sh, or 3-office-proxy.yml with 3-try.sh. The README in the folder covers all three.

The full output of my runs is in 1-ssh-tunnel.txt, 2-proxy-provider.txt and 3-office-proxy.txt, with the options I left out above. The Squid log in job 3 comes from the proxy, not the laptop: docker compose -f 3-office-proxy.yml exec squid cat /var/log/squid/access.log.

Fixing it in code

Change the start of the address your proxy service gave you. The username, password, host and port stay the same.

In Python, install SOCKS5 support first with pip install "requests[socks]":

python
import requests

proxy = "socks5://user:[email protected]:1080"  # the proxy address your proxy service gave you
proxy = proxy.replace("socks5://", "socks5h://", 1)

r = requests.get("https://example.com", proxies={"http": proxy, "https": proxy}, timeout=10)

Same with curl:

bash
curl -x socks5h://user:[email protected]:1080 https://example.com

If you have a server you can reach over SSH, like in the scp article, ssh -D 1080 user@server opens your own SOCKS5 proxy. Its address is socks5h://127.0.0.1:1080.

Which one to use

  • Most of the time, socks5h://. Your ISP’s DNS server doesn’t see which sites you visit.
  • On an HTTP proxy, change nothing. The proxy already resolves hostnames.
  • Use socks5:// only when you want your own computer to resolve the hostname on purpose. For example, when you’ve written an IP for a site in your hosts file.

One note: SOCKS5 doesn’t encrypt traffic. With socks5h:// your DNS lookups stay away from your ISP, but someone watching the connection to the proxy can still read the hostname. An encrypted tunnel prevents that, for example a proxy you open with ssh -D.

References

  1. RFC 1928: SOCKS Protocol Version 5
  2. RFC 9110: HTTP Semantics, CONNECT
  3. RFC 9112: HTTP/1.1, absolute-form
  4. Everything curl: SOCKS proxy
  5. Requests: SOCKS proxies
  6. urllib3: SOCKS proxies
  7. Chromium: Proxy support in Chrome
  8. Mozilla Bugzilla 1741375: Proxy DNS by default when using SOCKS v5
  9. git: http: differentiate socks5:// and socks5h://
  10. socks-proxy-agent source
  11. Kubernetes: Use a SOCKS5 Proxy to Access the Kubernetes API
  12. Bright Data: SOCKS5
  13. npm: config, proxy
  14. Visual Studio Code: Network Connections
  15. RFC 7686: The .onion Special-Use Domain Name

Written by:

Full Stack Software EngineerSamsun, Türkiye

Full Stack Software Engineer. I started with client sites at an agency in 2019, then worked on embeds, a dashboard and analytics at a startup called Popupsmart.