SOCKS5 DNS handling explained
SOCKS5 vs SOCKS5h: Difference, DNS Handling & cURL Examples
Quick answer: In cURL, socks5:// resolves the destination hostname locally before connecting through the proxy. socks5h:// sends the hostname to the SOCKS5 proxy so the proxy resolves it remotely. Use socks5h:// when proxy-side DNS resolution is required.
SOCKS5h is not a separate proxy protocol. It is a client-side notation for using a SOCKS5 proxy while asking that proxy to resolve the destination hostname.
SOCKS5 vs SOCKS5h Comparison
The underlying proxy protocol is SOCKS5 in both cases. The practical difference is where the destination hostname is converted into an IP address.
| Feature | socks5:// |
socks5h:// |
|---|---|---|
| Destination DNS lookup | Performed locally by cURL. | Performed by the SOCKS5 proxy. |
| What cURL sends to the proxy | The resolved destination IP address. | The original destination hostname. |
| Equivalent cURL option | --socks5 |
--socks5-hostname |
| When to use it | When local DNS is acceptable or deliberately required. | When the proxy should resolve the destination hostname. |
| Local DNS resolver involved | Yes, for the destination hostname. | Normally no, for the destination hostname requested through that cURL connection. |
| Proxy authentication | Supported. | Supported. |
Important: “SOCKS5h” describes remote hostname resolution in supporting clients. It does not mean a different server type, stronger encryption, or automatic anonymity.
Local DNS vs Proxy-Side DNS
Local DNS with socks5://
cURL asks the local DNS resolver for the IP address of the destination, such as example.com. It then gives the resulting IP address to the SOCKS5 proxy.
Remote DNS with socks5h://
cURL gives the hostname itself to the SOCKS5 proxy. The proxy resolves that hostname and opens the connection to the returned destination IP.
Why does proxy-side DNS matter?
Remote DNS keeps the destination hostname lookup inside the proxy connection handled by that client. This can be useful when local DNS results differ by network, when an internal resolver cannot resolve the target correctly, or when you want destination DNS handling to follow the proxy route.
It can also reduce local exposure of destination lookups from that specific cURL request. However, it does not control DNS requests made by other applications, browser extensions, operating-system services, WebRTC, or software that ignores the proxy setting.
The proxy hostname may still need local DNS
If the SOCKS5 proxy address itself is a hostname, your device may still need to resolve that proxy hostname before it can connect. Use the assigned proxy IP address when you want to avoid that separate lookup.
cURL SOCKS5 and SOCKS5h Examples
Replace PROXY_IP, PORT, USERNAME, and PASSWORD with the credentials supplied for your proxy.
Use socks5:// with local DNS
curl --max-time 15 --proxy 'socks5://USERNAME:PASSWORD@PROXY_IP:PORT' 'https://ifconfig.me/ip'
In this form, cURL resolves the destination hostname locally and then connects through the SOCKS5 proxy.
Use socks5h:// with proxy-side DNS
curl --max-time 15 --proxy 'socks5h://USERNAME:PASSWORD@PROXY_IP:PORT' 'https://ifconfig.me/ip'
In this form, cURL sends the destination hostname to the proxy for resolution.
Equivalent cURL options
Local DNS
curl --max-time 15 \
--socks5 'PROXY_IP:PORT' \
--proxy-user 'USERNAME:PASSWORD' \
'https://ifconfig.me/ip'
Proxy-side DNS
curl --max-time 15 \
--socks5-hostname 'PROXY_IP:PORT' \
--proxy-user 'USERNAME:PASSWORD' \
'https://ifconfig.me/ip'
Verbose troubleshooting
curl -v --max-time 15 \
--socks5-hostname 'PROXY_IP:PORT' \
--proxy-user 'USERNAME:PASSWORD' \
'https://www.google.com/'
The -v option shows connection and proxy-negotiation details. It can help identify an incorrect port, failed authentication, timeout, or destination connection error.
Password note: Using --proxy-user is easier when credentials contain shell-sensitive characters. Credentials embedded in a proxy URL may need URL encoding.
Environment variable examples
export ALL_PROXY='socks5://USERNAME:PASSWORD@PROXY_IP:PORT'
curl --max-time 15 'https://ifconfig.me/ip'
export ALL_PROXY='socks5h://USERNAME:PASSWORD@PROXY_IP:PORT'
curl --max-time 15 'https://ifconfig.me/ip'
Unset the variable after testing:
unset ALL_PROXY
Should You Use SOCKS5 or SOCKS5h?
Use socks5:// when:
- Local DNS is acceptable.
- You deliberately need the local resolver’s result.
- The application does not support remote hostname resolution.
- You are troubleshooting whether the local resolver is the source of a problem.
Use socks5h:// when:
- The SOCKS5 proxy should resolve destination hostnames.
- Local DNS returns incorrect or inaccessible destination addresses.
- You want DNS handling for that connection to follow the proxy route.
- The application explicitly supports
socks5h://or an equivalent remote-DNS setting.
For most cURL tests where proxy-side DNS is desired, use socks5h:// or --socks5-hostname. For complete browser and application setup instructions, follow the SOCKS5 proxy configuration guide.
What SOCKS5h Does Not Do
- It does not encrypt traffic by itself. HTTPS still provides encryption for HTTPS destinations.
- It does not force every application on the device to use the proxy.
- It does not prevent browser leaks caused by separate features or extensions.
- It does not guarantee access to a third-party website.
- It does not change the physical location or network ownership of the proxy IP.
Dedicated IPv4 SOCKS5 plans
Need a Stable SOCKS5 Proxy?
HighProxies provides dedicated SOCKS5 proxy IPs with monthly plans, multiple locations where available, unlimited bandwidth on listed plans, and username/password or IP authentication.
SOCKS5 vs SOCKS5h FAQ
Is SOCKS5h a different proxy protocol?
No. Both modes use SOCKS5. The “h” is client notation indicating that the hostname should be resolved by the proxy rather than locally.
Does socks5:// use local DNS in cURL?
Yes. In cURL, socks5:// and --socks5 resolve the destination hostname locally.
Does socks5h:// use remote DNS in cURL?
Yes. In cURL, socks5h:// and --socks5-hostname ask the SOCKS5 proxy to resolve the destination hostname.
Does SOCKS5h prevent every DNS leak?
No. It controls destination hostname resolution for applications and connections that correctly support it. Other applications or device services may still perform their own DNS lookups.
Where can I find full SOCKS5 setup instructions?
Use the HighProxies SOCKS5 configuration guide for Windows, Firefox, Chrome, AdsPower, GPM Browser, and cURL.