socks5h vs socks5: Who Resolves the Hostname (DNS)
One letter decides whether your DNS lookup runs on your computer or on the proxy.
socks5 and socks5h: the one difference
SOCKS5 is one protocol. When a client asks the proxy to connect somewhere, the request carries an address type: an IPv4 address, an IPv6 address or a domain name (RFC 1928 lists them as 1, 4 and 3). The client decides which one to send.
curl documents the two schemes this way: socks5:// uses the proxy but resolves the hostname locally, and socks5h:// lets the proxy resolve it. So socks5 sends the proxy an IP the client already looked up, and socks5h sends the bare name. Nothing else about the connection changes.
Sources: curl manual, Requests documentation, Chromium proxy notes and the Firefox source, all read on 16 November 2026. In Mozilla's source the Firefox preference defaults to false; check the value in about:config.
A name that only the proxy side can resolve fails with socks5. Typical cases are a host name on a private network behind the proxy, or a name your local resolver cannot answer. With socks5h the same name works because the lookup happens where the proxy is.
Some services answer a DNS question differently depending on where it comes from. With socks5h the lookup is made from the proxy's location, the same place the connection leaves from. With socks5 the answer is for your location, and the proxy is then asked to connect to that address.
With socks5 your own resolver sees every hostname you visit through the proxy. With socks5h it does not, because the name goes to the proxy inside the SOCKS request. When the target is already an IP address, such as http://93.184.216.34/, both behave the same, since there is nothing to resolve.
Neither is the right answer for every job. If a name must resolve with your local or company DNS, use socks5. For a proxy you rent to reach the public internet, socks5h is the usual choice because name and connection then come from the same place.
Save the stand-in server below as fake_socks5.py and run python3 fake_socks5.py. It listens on 127.0.0.1:18080 and prints what each client asks for.
Step 2
In a second terminal run curl with socks5:// and a name that exists nowhere, only-on-proxy.test (the .test ending is reserved for examples and never resolves).
Step 3
Run the same request with socks5h://.
Step 4
Compare. With socks5, curl says it could not resolve the host and the server prints nothing. With socks5h, the server prints ATYP 3 and the name: it was handed a domain name.
A 25-line SOCKS5 stand-in that logs the address type
# fake_socks5.py: prints what the client asked for, then answers "connection refused"
import socket, threading
srv = socket.socket()
srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
srv.bind(("127.0.0.1", 18080))
srv.listen(5)
def handle(c):
try:
c.recv(262)
c.sendall(b"\x05\x00") # greeting: no authentication
d = c.recv(262) # CONNECT request
if len(d) < 5:
return
atyp = d[3]
if atyp == 3:
addr = d[5:5 + d[4]].decode() # a domain name
elif atyp == 1:
addr = socket.inet_ntoa(d[4:8]) # an IPv4 address
else:
addr = "ipv6"
print("ATYP", atyp, addr, flush=True)
c.sendall(b"\x05\x05\x00\x01\x00\x00\x00\x00\x00\x00") # reply 5 = connection refused
finally:
c.close()
while True:
conn, _ = srv.accept()
threading.Thread(target=handle, args=(conn,)).start()
Local example: it refuses every connection after logging, so nothing leaves your machine. Python 3 standard library only.
curl: socks5 against socks5h
curl -sS -m 5 -x socks5://127.0.0.1:18080 http://only-on-proxy.test/
# curl: (97) Could not resolve host: only-on-proxy.test
# (the server prints nothing: curl never got as far as the proxy)
curl -sS -m 5 -x socks5h://127.0.0.1:18080 http://only-on-proxy.test/
# curl: (97) Can't complete SOCKS5 connection to only-on-proxy.test. (5)
# the server prints: ATYP 3 only-on-proxy.test
Output from curl 8.7.1 on macOS; the wording of curl's messages differs between versions. Error 97 here is the stand-in refusing the connection on purpose.
Python requests and environment variables
Requests follows the same rule: its documentation says socks5 makes DNS resolution happen on the client and socks5h makes the proxy resolve the domain. SOCKS support needs the extra package: pip install 'requests[socks]'.
Proxy variables work the same way. Requests reads ALL_PROXY, and curl reads it too, so the scheme you put in the variable decides who resolves. In our local run requests showed the same split: with socks5 the name failed on the client, with socks5h the request reached the stand-in. The full setup for each tool is in the two guides linked below.
# pip install 'requests[socks]'
import requests
proxy = "socks5h://LOGIN:PASSWORD@HOST:PORT" # h = the proxy looks the name up
proxies = {"http": proxy, "https": proxy}
r = requests.get("https://ipinfo.io/json", proxies=proxies, timeout=15)
print(r.json()["ip"])
Example only: replace the placeholder values with your own.
ALL_PROXY with socks5h
# the scheme in the variable decides who resolves, just like -x
export ALL_PROXY="socks5h://LOGIN:PASSWORD@HOST:PORT"
curl https://ipinfo.io/json
Example only: replace the placeholder values with your own.
When the result is not what you expected
"Could not resolve host" with a socks5 proxy
Check Does the name resolve on your own computer? Run nslookup NAME.
Fix If it does not, switch to socks5h:// so the proxy looks it up, or fix local DNS.
Stop when If socks5h gives the same error, stop: the proxy side cannot resolve it either, so check the spelling of the name.
Check Code 5 is "connection refused" in RFC 1928: the proxy got the name and tried, but the target refused or the port is closed.
Fix Check the target port and that the site is up; try the same request with an IP address to separate DNS from the connection.
Stop when If an IP also fails, the problem is the target or the proxy account, not DNS.
Chrome refuses a SOCKS5 proxy with a login
Check Chrome does not support username and password for SOCKS5, whatever the DNS setting.
Fix Give the browser an HTTP endpoint instead; the guide below shows how with the same login.
Stop when Do not look for a socks5h switch in Chrome: it always resolves on the proxy side already.
Firefox resolves locally although you chose SOCKS5
Check The preference network.proxy.socks_remote_dns decides, and its default in the source is false.
Fix Open about:config, set it to true and reload the page.
Stop when If a page still fails after that, test the proxy with curl first to rule out the browser.
On Proxy302: which protocol to pick
Proxy302 endpoints speak both protocols: HTTP on port 2222 and SOCKS5 on port 3333. A static ISP IP asset is issued with one protocol, shown in My assets, and has no protocol switch there. If yours is SOCKS5, write socks5h:// in curl, requests and other tools that accept the scheme; if it is HTTP, the DNS question does not arise because the HTTP proxy always receives the hostname.
A static ISP IP keeps its address for the whole lease: US$0.50 for 1 day or US$7.99 for 30 days, the same in every country. There is no free trial, and the smallest purchase is one IP for one day.
Open the static residential page, choose the country, set Protocol to SOCKS5 and place the order.
Step 2
Open My assets (the console page that holds everything you bought) and copy HOST, PORT, USERNAME and PASSWORD.
Step 3
Build the address as socks5h://USERNAME:PASSWORD@HOST:PORT and pass it to curl with -x or to requests in proxies.
Step 4
Run curl -x socks5h://... https://ipinfo.io/json and confirm the IP and country shown.
socks5h FAQ
Is socks5h a different protocol from socks5?
No. On the wire both are SOCKS5. The h is only a client-side setting that tells the tool whether to send the proxy a name or an IP.
Which one should I use by default?
For a rented proxy that reaches the public internet, socks5h. Use socks5 when the name must be resolved by your own DNS, for example a host on your office network.
Does Chrome have socks5h?
No, and it does not need it. The Chromium notes say that for SOCKSv5 name resolution is always done on the proxy side.
How can I tell which one my tool used?
Look at what the proxy receives: a domain name means the proxy resolved it, an IP means your computer did. The local test on this page shows both cases. A failure that says the host could not be resolved before any connection means your own DNS failed.
Does the h change anything for an HTTP proxy?
No. An HTTP proxy is given the hostname in the request line or the CONNECT line, so it always resolves the name itself.
Check the exit IP, country and ISP your proxy really gives you in 30 seconds — and why IP databases disagree on the city. With our own test of three lookup services.
SOCKS5 on all three lines: rotating residential from US$1.50/GB, static ISP and datacenter IPs per IP and term. Port 3333 with username and password, and the errors you see when a setting is wrong.
Read on 16 November 2026: socks5:// and socks5h:// are listed as proxy schemes; --socks5 is described as using a SOCKS5 proxy but resolving the hostname locally, and --socks5-hostname (the same as socks5h://) as letting the proxy resolve the hostname.
Read on 16 November 2026: the CONNECT request carries an address type (ATYP): X'01' IPv4, X'03' domain name, X'04' IPv6; reply code X'05' means connection refused.
Read on 16 November 2026: the socks5 scheme makes DNS resolution happen on the client; socks5h makes the proxy resolve the domain; SOCKS support needs pip install requests[socks]; proxy URLs can also come from ALL_PROXY.
Read on 16 November 2026: for SOCKSv5 name resolution is always done proxy side, Chrome has no option to choose; the page also mentions Firefox's network.proxy.socks_remote_dns setting.
Read on 16 November 2026: the preference network.proxy.socks_remote_dns exists and its default value is false.
Local test with curl 8.7.1 and requests 2.32.5
Local example · Confirmed on:
Run on 16 November 2026 against a 25-line SOCKS5 stand-in on 127.0.0.1 (code on this page). With socks5 the hostname failed to resolve on the client and the stand-in saw nothing; with socks5h the stand-in received the name as a domain-name address.
Proxy302 product facts and price list
Product observation · Confirmed on:
Product facts file of the site (values checked against the console, the backend and the price table on 18-19 October 2026): products, prices in US$ (1 PTC = US$1), lease terms, protocols and ports.
Ready to try it?
Create an account, top up once, then pick rotating residential, static ISP or datacenter IPs and have one running in your browser within minutes.