# SOCKS5h vs SOCKS5: Who Resolves the Hostname | ProxyJam

SOCKS5h vs SOCKS5: the h moves the DNS lookup from your machine to the proxy. What that changes, and how to set it in curl, Python, Node and browsers.

- Canonical: https://proxyjam.com/blog/socks5h-vs-socks5/
- Updated: 2026-11-30
- Language: en

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.


## What each client does with socks5 and socks5h

|  | With socks5:// | With socks5h:// |
|---|---|---|
| curl | Your machine resolves the name | The proxy resolves the name |
| Python requests | Your machine resolves the name | The proxy resolves the name |
| Python httpx | The proxy resolves the name in our test; the docs do not say | Accepted since 0.28.0; the proxy resolves the name |
| Node with socks-proxy-agent | Your machine resolves the name | The proxy resolves the name |
| Chrome | The proxy resolves the name | Not a scheme Chromium lists |
| Firefox | Set by Proxy DNS when using SOCKS v5, on by default since Firefox 128 | Not a setting; the checkbox decides |

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.


## 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.

### 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.

### 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.


## Sources

- [RFC 1928: SOCKS Protocol Version 5](https://www.rfc-editor.org/rfc/rfc1928), section 4: a request names its destination as an IPv4 address, a domain name or an IPv6 address
- [RFC 1929: Username/Password Authentication for SOCKS V5](https://www.rfc-editor.org/rfc/rfc1929), the sign-in that sends the password in clear text
- [RFC 9110, section 9.3.6: CONNECT](https://www.rfc-editor.org/rfc/rfc9110.html#section-9.3.6), an HTTP proxy receives the host and port by name
- [RFC 7871: Client Subnet in DNS Queries](https://www.rfc-editor.org/rfc/rfc7871), authoritative servers that answer by the location of the resolver asking
- [curl man page](https://curl.se/docs/manpage.html), the socks4, socks4a, socks5 and socks5h schemes of the proxy option and the options that match them
- [Everything curl: SOCKS proxy](https://everything.curl.dev/usingcurl/proxies/socks.html), which end resolves the name for each SOCKS version
- [Requests documentation: SOCKS](https://requests.readthedocs.io/en/latest/user/advanced/#socks), socks5 resolves on the client, socks5h on the proxy, and the requests[socks] extra
- [HTTPX documentation: Proxies](https://www.python-httpx.org/advanced/proxies/), the proxy argument and the httpx[socks] extra
- [HTTPX changelog](https://github.com/encode/httpx/blob/master/CHANGELOG.md), version 0.28.0: socks5h treated as a valid proxy scheme
- [socks-proxy-agent source](https://github.com/TooTallNate/proxy-agents/blob/main/packages/socks-proxy-agent/src/index.ts), the schemes it accepts and which of them look the name up locally
- [Chromium: proxy support notes (proxy.md)](https://chromium.googlesource.com/chromium/src/+/HEAD/net/docs/proxy.md), SOCKS5 names always resolved at the proxy, and no SOCKS5 authentication
- [Mozilla bug 1741375: Proxy DNS by default when using SOCKS v5](https://bugzilla.mozilla.org/show_bug.cgi?id=1741375), fixed in Firefox 128
- [Firefox preference list (StaticPrefList.yaml)](https://github.com/mozilla-firefox/firefox/blob/main/modules/libpref/init/StaticPrefList.yaml), network.proxy.socks5_remote_dns on by default




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](https://curl.se/docs/manpage.html) 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](https://www.rfc-editor.org/rfc/rfc1928)
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](https://www.rfc-editor.org/rfc/rfc7871) 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](/blog/view-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](/socks5-proxies/) 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](/blog/how-to-use-static-ip-proxy/) shows
where to find.

### curl

```sh
# 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](https://requests.readthedocs.io/en/latest/user/advanced/#socks)
says that `socks5` resolves on the client and that you should use `socks5h` to
resolve on the proxy server.

```python
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](/integrations/python-requests/)
has the session and environment variable versions.

### Python httpx

httpx takes one `proxy` argument and needs `pip install 'httpx[socks]'`. Its
[proxy documentation](https://www.python-httpx.org/advanced/proxies/) shows
only a `socks5://` URL and does not say which end resolves the name. The
[changelog](https://github.com/encode/httpx/blob/master/CHANGELOG.md) for
0.28.0 adds `socks5h` as a valid proxy scheme.

```python
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](https://github.com/TooTallNate/proxy-agents/tree/main/packages/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.

```js
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](https://chromium.googlesource.com/chromium/src/+/HEAD/net/docs/proxy.md)
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](/blog/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](https://bugzilla.mozilla.org/show_bug.cgi?id=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](https://www.rfc-editor.org/rfc/rfc1929),
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](/blog/proxy-authentication-methods/) 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:

```text
* 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](/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](/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](/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](/pricing/), and the [SOCKS5 page](/socks5-proxies/) explains
the protocol and the switch in more detail.

