AI summary
With a SOCKS5Version 5 of SOCKS, a protocol for talking to a proxy. A proxy address that uses it starts with socks5:// or socks5h://. proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. at socks5://, your computer does the DNSThe internet's phone book. It turns a hostname like example.com into an IP address. lookup, so your ISPInternet service provider: the company your internet connection comes from.'s DNSThe internet's phone book. It turns a hostname like example.com into an IP address. server sees each hostnameThe name of the machine you want to reach, like shop.example or example.com. In a browser, it's the part between https:// and the first /.. With socks5h:// or an HTTP proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours., the proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. does it.
A proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. is a server that opens connections for you. The site sees the proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours.’s IP address, not yours.
But even with a proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours., someone else can still see which sites you visit. Whether they can comes down to one letter at the start of the proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. address: socks5:// or socks5h://.
I set up socks5://, socks5h:// and an HTTP proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. in a small DockerA tool that runs programs in containers, each with its own files and network. The lab uses it to build small networks on your computer. 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 hostnameThe name of the machine you want to reach, like shop.example or example.com. In a browser, it's the part between https:// and the first /. is a machine’s name, like shop.example. Before connecting to it, your computer asks a DNSThe internet's phone book. It turns a hostname like example.com into an IP address. server: “what’s the IP address of shop.example?” That question is a DNSThe internet's phone book. It turns a hostname like example.com into an IP address. lookup.
This is also called resolvingTo look up a hostname's IP address. Your computer, or a proxy, asks a DNS server and gets the IP back. the hostnameThe name of the machine you want to reach, like shop.example or example.com. In a browser, it's the part between https:// and the first /..
Normally that lookup goes to your ISPInternet service provider: the company your internet connection comes from.’s or your office network’s DNSThe internet's phone book. It turns a hostname like example.com into an IP address. server. That server sees every site you visit.
Three options, one difference
SOCKS5Version 5 of SOCKS, a protocol for talking to a proxy. A proxy address that uses it starts with socks5:// or socks5h://. and HTTP are two protocols a program can use to talk to a proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours.. A proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. address can start in three ways. The difference is who does the DNSThe internet's phone book. It turns a hostname like example.com into an IP address. lookup:
socks5://: your computer does the DNSThe internet's phone book. It turns a hostname like example.com into an IP address. lookup. Only an IP goes to the proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours..socks5h://: the proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. does the DNSThe internet's phone book. It turns a hostname like example.com into an IP address. lookup. The hostnameThe name of the machine you want to reach, like shop.example or example.com. In a browser, it's the part between https:// and the first /. goes to the proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours..http://: likesocks5h://. The proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. does the DNSThe internet's phone book. It turns a hostname like example.com into an IP address. lookup.
The h in socks5h stands for hostnameThe name of the machine you want to reach, like shop.example or example.com. In a browser, it's the part between https:// and the first /..
So with socks5:// your DNSThe internet's phone book. It turns a hostname like example.com into an IP address. lookups still go to your ISPInternet service provider: the company your internet connection comes from., even though you’re using a proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours.. That’s called a DNSThe internet's phone book. It turns a hostname like example.com into an IP address. leak.
socks5:// · Kubernetes API over an SSH tunnel
Your company’s KubernetesA system that runs and manages containers across a group of servers, called a cluster. You control it through its API. cluster isn’t open to the internet.
Only the company’s SSHAn encrypted way to log in to another machine's terminal over the network. It can also carry other connections, which is what ssh -D uses. 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 kubectlKubernetes's command-line tool. It sends your commands to the cluster's API.’s config.
ssh -D 1080 opens a SOCKS5Version 5 of SOCKS, a protocol for talking to a proxy. A proxy address that uses it starts with socks5:// or socks5h://. proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. on your laptop’s portA number that says which program on a machine a connection is for. Websites usually use 80 and 443. 1080 that sends everything through the bastion.
kubectlKubernetes's command-line tool. It sends your commands to the cluster's API. sends that proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. a CONNECT request: the address and portA number that says which program on a machine a connection is for. Websites usually use 80 and 443. it wants a connection to. SSHAn encrypted way to log in to another machine's terminal over the network. It can also carry other connections, which is what ssh -D uses. 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 hostnameThe name of the machine you want to reach, like shop.example or example.com. In a browser, it's the part between https:// and the first /. to resolveTo look up a hostname's IP address. Your computer, or a proxy, asks a DNS server and gets the IP back., and your DNSThe internet's phone book. It turns a hostname like example.com into an IP address. server never comes into it.
That changes once the address is a hostnameThe name of the machine you want to reach, like shop.example or example.com. In a browser, it's the part between https:// and the first /..
The guide notes this too: with socks5h, the bastion resolvesTo look up a hostname's IP address. Your computer, or a proxy, asks a DNS server and gets the IP back. the hostnameThe name of the machine you want to reach, like shop.example or example.com. In a browser, it's the part between https:// and the first /., so it never reaches your DNSThe internet's phone book. It turns a hostname like example.com into an IP address. server.
socks5://
Your laptop already knows the API's IP. The tunnel carries that IP to the bastion. Your DNS is never asked.
- Your laptop → BastionAsks for 10.89.1.10:6443; SSH carries it through the tunnel
- Bastion → Kubernetes APIThe bastion passes the request to the API
- Kubernetes API → BastionThe answer comes back through the tunnel
curl --max-time 3 http://10.89.1.10:6443/versioncurl: (28) Connection timed out after 3002 millisecondsWithout the tunnel the API can't be reached.
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.2With an IP, socks5:// is enough. The API sees the request coming from the bastion.
curl -x socks5://127.0.0.1:1080 http://k8s-api.internal:6443/versioncurl: (97) Could not resolve proxy: 127.0.0.1Only 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.
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.2With socks5h:// the bastion resolves the hostname.
socks5h:// · Collecting data from another country
Companies that track prices or collect data use proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. providers so their requests look like they come from another country.
One of the big providers, Bright Data, only accepts socks5h on its SOCKS5Version 5 of SOCKS, a protocol for talking to a proxy. A proxy address that uses it starts with socks5:// or socks5h://. service, as its docs say.
It refuses requests that send the target as an IP, because an IP means the client already resolvedTo look up a hostname's IP address. Your computer, or a proxy, asks a DNS server and gets the IP back. the hostnameThe name of the machine you want to reach, like shop.example or example.com. In a browser, it's the part between https:// and the first /. itself. Bright Data says it does this for compliance.
For collecting data from another country, you’d want socks5h:// anyway: many big sites answer DNSThe internet's phone book. It turns a hostname like example.com into an IP address. lookups with the server closest to whoever asks.
Say your price-tracking script runs in Turkey, and the proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. is in Germany. If the script resolvesTo look up a hostname's IP address. Your computer, or a proxy, asks a DNS server and gets the IP back. the hostnameThe name of the machine you want to reach, like shop.example or example.com. In a browser, it's the part between https:// and the first /. itself, your DNSThe internet's phone book. It turns a hostname like example.com into an IP address. 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 resolvesTo look up a hostname's IP address. Your computer, or a proxy, asks a DNS server and gets the IP back. the hostnameThe name of the machine you want to reach, like shop.example or example.com. In a browser, it's the part between https:// and the first /., and the script talks to the server in Germany.
socks5h://
The hostname goes to the provider, which resolves it in Germany.
- Your script → ProviderCONNECT shop.example:80, as a hostname
- Provider → Provider's DNSWhat's the IP of shop.example?
- Provider's DNS → Provider10.90.0.22, the server in Germany
- Provider → shop.exampleGET /, to the server in Germany
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.
curl -x socks5h://provider:1080 http://shop.example/shop.example, the server in Germany. Request came from 10.90.0.10The provider resolved the hostname, and the answer came from the server in Germany.
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.
grep -o 'query\[A\] shop.example.*' /logs/my-dns.logquery[A] shop.example from 10.90.0.100The 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 proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours..
Developer tools document a setting for it, like npm’s proxy option or VS Code’s proxy support.
Most of these proxiesA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. are HTTP proxiesA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. like Squid.
The laptop doesn’t resolveTo look up a hostname's IP address. Your computer, or a proxy, asks a DNS server and gets the IP back. the hostnameThe name of the machine you want to reach, like shop.example or example.com. In a browser, it's the part between https:// and the first /.. For a plain HTTP page it sends the proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. the whole address, like GET http://registry.example/.
For HTTPS the laptop wants an encrypted connection straight to the site, so the proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. can’t read the request. The laptop first sends CONNECT registry.npmjs.org:443, and the proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. opens a tunnel to that address: the same CONNECT idea, this time in HTTP.
Because the proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. resolvesTo look up a hostname's IP address. Your computer, or a proxy, asks a DNS server and gets the IP back. the hostnameThe name of the machine you want to reach, like shop.example or example.com. In a browser, it's the part between https:// and the first /., the company can log which sites people visit and block the ones it doesn’t allow.
http://
Your laptop hands the whole address to the proxy. The proxy resolves the hostname and logs the request.
- Your laptop → SquidGET http://registry.example/
- Squid → Proxy's DNSWhat's the IP of registry.example?
- Proxy's DNS → Squid10.91.0.21
- Squid → registry.exampleGET /, and the request is logged
curl http://registry.example/curl: (6) Could not resolve host: registry.exampleThe laptop can't resolve the hostname itself.
curl -x http://squid:3128 http://registry.example/registry.example, the package registry. Request came from 10.91.0.10The proxy resolved the hostname and let the request through.
curl -o /dev/null -w %{http_code} -x http://squid:3128 http://games.example/403A blocked site: the proxy answers itself.
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 SOCKS5Version 5 of SOCKS, a protocol for talking to a proxy. A proxy address that uses it starts with socks5:// or socks5h://. proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours., the proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. always resolvesTo look up a hostname's IP address. Your computer, or a proxy, asks a DNS server and gets the IP back. the hostnameThe name of the machine you want to reach, like shop.example or example.com. In a browser, it's the part between https:// and the first /.. There’s no setting to change.
- Firefox: since version 128 the proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. resolvesTo look up a hostname's IP address. Your computer, or a proxy, asks a DNS server and gets the IP back. the hostnameThe name of the machine you want to reach, like shop.example or example.com. In a browser, it's the part between https:// and the first /. by default. The “ProxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. DNSThe internet's phone book. It turns a hostname like example.com into an IP address. when using SOCKS v5” option now comes switched on.
- curl:
socks5://resolvesTo look up a hostname's IP address. Your computer, or a proxy, asks a DNS server and gets the IP back. the hostnameThe name of the machine you want to reach, like shop.example or example.com. In a browser, it's the part between https:// and the first /. on your computer. Usesocks5h://or--socks5-hostname. - Python’s requests:
socks5://resolvesTo look up a hostname's IP address. Your computer, or a proxy, asks a DNS server and gets the IP back. on your computer,socks5h://on the proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours.. - git: write
git config http.proxy socks5h://.... git has known the difference since 2016; older versions treatedsocks5h://likesocks5://. - socks-proxy-agent in Node.js:
socks5://resolvesTo look up a hostname's IP address. Your computer, or a proxy, asks a DNS server and gets the IP back. on your computer,socks5h://and plainsocks://on the proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours.. - TorA network that sends your traffic through several volunteer servers, so no single one knows both who you are and where you're going. Sites inside it have .onion addresses. It runs a SOCKS5 proxy on your computer.: ordinary DNS can’t resolve
.onionaddresses; only TorA network that sends your traffic through several volunteer servers, so no single one knows both who you are and where you're going. Sites inside it have .onion addresses. It runs a SOCKS5 proxy on your computer. can. If you point curl or Python at TorA network that sends your traffic through several volunteer servers, so no single one knows both who you are and where you're going. Sites inside it have .onion addresses. It runs a SOCKS5 proxy on your computer. withsocks5://127.0.0.1:9050instead ofsocks5h://127.0.0.1:9050, a.onionpage never opens.
Try it yourself
You can run all three jobs on your own computer with DockerA tool that runs programs in containers, each with its own files and network. The lab uses it to build small networks on your computer..
Download the lab as a zip, unpack it and start the job you want:
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 -vFor 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 proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours., 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 proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. service gave you. The username, password, host and portA number that says which program on a machine a connection is for. Websites usually use 80 and 443. stay the same.
In Python, install SOCKS5Version 5 of SOCKS, a protocol for talking to a proxy. A proxy address that uses it starts with socks5:// or socks5h://. support first with pip install "requests[socks]":
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:
curl -x socks5h://user:[email protected]:1080 https://example.comIf you have a server you can reach over SSHAn encrypted way to log in to another machine's terminal over the network. It can also carry other connections, which is what ssh -D uses., like in the scp article, ssh -D 1080 user@server opens your own SOCKS5Version 5 of SOCKS, a protocol for talking to a proxy. A proxy address that uses it starts with socks5:// or socks5h://. proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours.. Its address is socks5h://127.0.0.1:1080.
Which one to use
- Most of the time,
socks5h://. Your ISPInternet service provider: the company your internet connection comes from.’s DNSThe internet's phone book. It turns a hostname like example.com into an IP address. server doesn’t see which sites you visit. - On an HTTP proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours., change nothing. The proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. already resolvesTo look up a hostname's IP address. Your computer, or a proxy, asks a DNS server and gets the IP back. hostnameThe name of the machine you want to reach, like shop.example or example.com. In a browser, it's the part between https:// and the first /.s.
- Use
socks5://only when you want your own computer to resolveTo look up a hostname's IP address. Your computer, or a proxy, asks a DNS server and gets the IP back. the hostnameThe name of the machine you want to reach, like shop.example or example.com. In a browser, it's the part between https:// and the first /. on purpose. For example, when you’ve written an IP for a site in your hosts fileA text file on your computer that maps hostnames to IP addresses by hand. Your computer checks it before asking DNS..
One note: SOCKS5Version 5 of SOCKS, a protocol for talking to a proxy. A proxy address that uses it starts with socks5:// or socks5h://. doesn’t encrypt traffic. With socks5h:// your DNSThe internet's phone book. It turns a hostname like example.com into an IP address. lookups stay away from your ISPInternet service provider: the company your internet connection comes from., but someone watching the connection to the proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. can still read the hostnameThe name of the machine you want to reach, like shop.example or example.com. In a browser, it's the part between https:// and the first /.. An encrypted tunnel prevents that, for example a proxyA server that opens connections for you. The site you reach sees the proxy's IP address instead of yours. you open with ssh -D.
References
- RFC 1928: SOCKS Protocol Version 5
- RFC 9110: HTTP Semantics, CONNECT
- RFC 9112: HTTP/1.1, absolute-form
- Everything curl: SOCKS proxy
- Requests: SOCKS proxies
- urllib3: SOCKS proxies
- Chromium: Proxy support in Chrome
- Mozilla Bugzilla 1741375: Proxy DNS by default when using SOCKS v5
- git: http: differentiate socks5:// and socks5h://
- socks-proxy-agent source
- Kubernetes: Use a SOCKS5 Proxy to Access the Kubernetes API
- Bright Data: SOCKS5
- npm: config, proxy
- Visual Studio Code: Network Connections
- RFC 7686: The .onion Special-Use Domain Name
