Change language
English Русский Deutsch Español Français Italiano Українська Tiếng Việt Türkçe Bahasa Indonesia हिन्दी 日本語 Português 中文
Menu
Pricing
Proxies
Solutions
Resources

SOCKS5h vs SOCKS5: What the h Means and Who Resolves the Hostname

Contents
  1. What does the h in socks5h mean?
  2. Why does it matter where the name is resolved?
  3. How do you use socks5h in curl, Python and Node?
  4. What do browsers do with a SOCKS5 proxy?
  5. Where do the username and password go?
  6. How do you check which one your client sends?
  7. What does ProxyJam sell for this?
  8. Quick answers

In short: The h stands for hostname. With socks5:// your client looks the hostname up itself and sends the proxy an address. With socks5h:// it sends the name, and the proxy does the lookup. The protocol is the same SOCKS5 either way. Use socks5h:// for regional checks, where the answer should come from the proxy’s side, and socks5:// for names that only resolve on your own network.

A SOCKS5 proxy can be given its destination in two forms: as a hostname, or as an IP address your machine has already looked up. The proxy URL decides which. socks5:// makes the client do the DNS lookup and send the address. socks5h:// makes it send the name, so the proxy does the lookup. This guide shows the two request flows, explains when the difference changes your results, sets the scheme in curl, Python, Node and the browsers, and shows how to see which form your client sent.

What does the h in socks5h mean?

It stands for hostname, and the convention is curl’s. The curl manual describes --socks5 as using the proxy “but resolve the hostname locally”, and --socks5-hostname as the variant that lets “the proxy resolve the hostname”. In a proxy URL, the schemes socks5:// and socks5h:// pick the same two behaviours. Python requests says its schemes are in line with curl, and the Node package socks-proxy-agent uses the same names, so the scheme reads the same across tools.

The protocol underneath does not change. RFC 1928 lets a connect request carry its destination as an IPv4 address, an IPv6 address or a domain name, and the h only says which of these the client fills in.

With socks5://HOST:PORT, a request for https://example.com/ runs like this:

  1. Your machine asks its own DNS resolver for example.com.
  2. The resolver answers with an address.
  3. The client asks the proxy to connect to that address.
  4. The proxy connects, and never sees the name.

With socks5h://HOST:PORT:

  1. The client asks the proxy to connect to example.com.
  2. The proxy asks its own resolver for the name.
  3. The proxy connects to the address its resolver returned.

Your machine makes no DNS query for the site in the second flow, and in both the site sees a connection from the proxy’s address.

Why does it matter where the name is resolved?

Because the answer to a DNS query can depend on who asks. Large sites and content delivery networks often give each region the address of a nearby server. RFC 7871 describes authoritative servers that “return different responses based on the perceived topological location of the user”, judged by the address of the resolver that asks them.

Say you test your own storefront from a static address in Germany while you sit in the United States. With socks5://, your resolver in the United States picks the server, and the proxy is then asked to fetch the page from a server chosen for American visitors. The exit address is German, the server answering it was picked for someone else, and a regional check can show content or timings that no visitor in Germany gets. With socks5h://, the lookup is made by the resolver the proxy uses, and the server is picked for the proxy’s side of the connection. The post on viewing your website from another country sets up the rest of such a check, from language to time zone.

Three other cases change the answer, whichever country you test from:

  • Names that only exist on your network. An internal hostname that your office DNS answers and public DNS does not will fail through socks5h://, because the proxy cannot resolve it. Use socks5:// for those, or the IP address itself.
  • IPv6 answers. With local resolution, your machine may get an IPv6 address and ask the proxy to reach it, which works only if the proxy’s own network can. With socks5h://, the proxy picks from the answers its own resolver gives.
  • Your own resolver. With socks5://, the lookup for each site goes to your own resolver. With socks5h://, your machine makes none, as our SOCKS5 page notes. The site you connect to receives the same request either way.

How do you use socks5h in curl, Python and Node?

Every example in this section sends the name to the proxy. To send an address instead, change the scheme to socks5://. Replace HOST, PORT and the credentials with the values on your order, which using your static IP after purchase shows where to find.

curl

# The proxy resolves the name
curl -x socks5h://USERNAME:PASSWORD@HOST:PORT https://example.com/

# The same, as separate options
curl --socks5-hostname HOST:PORT --proxy-user USERNAME:PASSWORD https://example.com/

# Your machine resolves the name
curl -x socks5://USERNAME:PASSWORD@HOST:PORT https://example.com/

curl’s manual says credentials in the proxy URL are URL-decoded, so encode special characters in the password. It also warns that a password on the command line is visible in the process list.

Python requests

requests needs its SOCKS extra, installed with python -m pip install 'requests[socks]'. Its documentation says that socks5 resolves on the client and that you should use socks5h to resolve on the proxy server.

import os
from urllib.parse import quote

import requests

user = quote(os.environ["PROXY_USER"], safe="")
password = quote(os.environ["PROXY_PASSWORD"], safe="")
proxy = "socks5h://" + user + ":" + password + "@HOST:PORT"

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

Set both keys. A dictionary with only http lets every HTTPS request leave from your own address. Our requests guide has the session and environment variable versions.

Python httpx

httpx takes one proxy argument and needs pip install 'httpx[socks]'. Its proxy documentation shows only a socks5:// URL and does not say which end resolves the name. The changelog for 0.28.0 adds socks5h as a valid proxy scheme.

import httpx

with httpx.Client(proxy="socks5h://USERNAME:PASSWORD@HOST:PORT", timeout=30) as client:
    r = client.get("https://example.com/")

In our test of httpx 0.28.1, both socks5:// and socks5h:// sent the hostname to the proxy. So in httpx the scheme does not switch the lookup to your machine; if a job needs your local DNS, requests with socks5:// does that.

Node.js

Node’s http and https modules accept an agent, and the socks-proxy-agent package supplies one for SOCKS. In its source, socks5 and socks4 look the name up locally, while socks5h, socks4a and a bare socks send it to the proxy.

import https from "node:https";
import { SocksProxyAgent } from "socks-proxy-agent";

const agent = new SocksProxyAgent("socks5h://USERNAME:PASSWORD@HOST:PORT");

https.get("https://example.com/", { agent: agent }, (res) => {
  console.log(res.statusCode);
  res.resume();
});

What do browsers do with a SOCKS5 proxy?

A browser’s proxy settings dialog takes a host and a port, with no scheme to add an h to, so each browser decides for itself.

Chrome always sends the name. Chromium’s proxy notes say that for SOCKS5 “name resolution is always done proxy side”, and that Chrome has no option to change it. The same notes say Chrome supports no SOCKS5 authentication, so a SOCKS5 password is never sent. Put the address you connect from on the proxy’s allowlist instead; the post on proxy authentication methods walks through it.

Firefox has a checkbox in its connection settings, Proxy DNS when using SOCKS v5. It is on by default since Firefox 128 (bug 1741375), and behind it is the preference network.proxy.socks5_remote_dns, which the browser’s own preference file describes as “making it a SOCKS5h proxy by convention”. Check the box once in your own profile before you rely on it.

Where do the username and password go?

In the URL, before the host: socks5h://USERNAME:PASSWORD@HOST:PORT. The h does not change that part. A slash, question mark, hash or percent sign in the password has to be percent-encoded, or the URL ends early.

SOCKS5 has its own sign-in, defined in RFC 1929, and it sends the password to the proxy in clear text. Anything you send inside the tunnel over HTTPS stays encrypted, but the proxy password itself does not. If a client cannot send a SOCKS5 password, as with Chrome, or you would rather store no password on a server, use an IP allowlist; the authentication guide compares the two methods and the errors each one produces.

How do you check which one your client sends?

curl tells you. Add -v and look for the SOCKS5 line. For a request to http://example.com/ it reads:

* SOCKS5 connect to 104.20.23.154:80 (locally resolved)
* SOCKS5 connect to example.com:80 (remotely resolved)

The first came from socks5://, the second from socks5h://, in our run of curl 8.7.1. The address will differ on your machine, and an https:// URL shows port 443. Libraries print no such line. For them, the table What each client does with socks5 and socks5h gives what each sent in our test, and the requests documentation and the socks-proxy-agent source match curl’s convention.

Two further checks confirm the rest of the path. Open What Is My IP through the proxy to see the exit address a site sees; it shows the same address with either scheme. The proxy checker tells you whether a proxy answers over SOCKS5 with your credentials before you put it in code. Run these on your own setup and on pages you are allowed to test.

What does ProxyJam sell for this?

Static residential (ISP) proxies: one address on a named internet provider’s network, yours for the period you pay for, in 76 countries. Every one runs HTTP or SOCKS5, switched on the order from the dashboard or the API, and the order then shows the port and credentials for the new protocol. Changing the scheme in your client is not enough on its own: a proxy still set to HTTP does not answer SOCKS5.

A static address is the wrong fit if each request needs a new IP. That takes a rotating pool, which we do not sell today. Prices are on the pricing page, and the SOCKS5 page explains the protocol and the switch in more detail.

What each client does with socks5 and socks5h

The curl, requests, httpx and Node rows come from each tool's documentation or source, and were checked on 2026-11-24 against a SOCKS5 listener on our own machine that logged whether each request carried a name or an address: curl 8.7.1, requests 2.34.2 with PySocks 1.7.1, httpx 0.28.1 with socksio 1.0.0, socks-proxy-agent 10.1.0 on Node 26. The browser rows are read from Chromium's proxy notes and Firefox's preference file and were not tested. A later release can change any of them.
With socks5://With socks5h://
curlYour machine resolves the nameThe proxy resolves the name
Python requestsYour machine resolves the nameThe proxy resolves the name
Python httpxThe proxy resolves the name in our test; the docs do not sayAccepted since 0.28.0; the proxy resolves the name
Node with socks-proxy-agentYour machine resolves the nameThe proxy resolves the name
ChromeThe proxy resolves the nameNot a scheme Chromium lists
FirefoxSet by Proxy DNS when using SOCKS v5, on by default since Firefox 128Not a setting; the checkbox decides

Quick answers

Is socks5h a different protocol from SOCKS5?

No. SOCKS5 is defined in RFC 1928. It already lets a client name its destination either by address or by domain name. socks5h is a URL scheme, used by curl and by clients that follow its convention, telling the client to send the name. The proxy sees an ordinary SOCKS5 request in both cases. SOCKS5

Should I use socks5h by default?

For a proxy you use to see how sites answer from another network, yes: the lookup then happens on that network too. Use socks5 when a hostname only exists in your own DNS, such as an internal name, because the proxy cannot resolve it.

Does an HTTP proxy have the same choice?

Not in the usual setup. A client sending a request through an HTTP proxy puts the hostname in the request, and for HTTPS the CONNECT request names the host and port (RFC 9110, section 9.3.6). The proxy then does the lookup itself, the way socks5h does.

Is SOCKS4a the same idea?

Yes, for the older protocol. SOCKS4 can only carry an IPv4 address, so the client resolves the name. SOCKS4a adds a way to send the name, and curl’s manual describes socks4a as asking the proxy to resolve the hostname. Chrome does not support SOCKS4a and resolves SOCKS4 names on the client.

Where do the username and password go in a socks5h URL?

Before the host, the same as for HTTP: socks5h://USERNAME:PASSWORD@HOST:PORT. Encode any slash, question mark, hash or percent sign in the password. SOCKS5 sends the password to the proxy in clear text (RFC 1929), and Chrome sends no SOCKS5 password at all, so Chrome on SOCKS5 needs the IP allowlist. Proxy authentication

Does the h change the exit IP address a site sees?

No. Both schemes connect through the same proxy, so the site sees the proxy’s address. What changes is which resolver answered the lookup, and therefore which server address the proxy was asked to connect to. What Is My IP

Sources