<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[BuyProxy Blog]]></title><description><![CDATA[BuyProxy Blog]]></description><link>https://buyproxyorg.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/6afc8d9d919be746c320625e/88e5505d-1675-4b94-bdfb-66de1e56f179.png</url><title>BuyProxy Blog</title><link>https://buyproxyorg.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Wed, 18 Nov 2026 13:49:11 GMT</lastBuildDate><atom:link href="https://buyproxyorg.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Your proxy hides your IP, but your DNS lookups still happen at home. One letter fixes it.]]></title><description><![CDATA[With socks5:// your own machine still looks up every hostname. We tested curl and Python against a logging SOCKS5 proxy to see what socks5h changes.]]></description><link>https://buyproxyorg.hashnode.dev/your-proxy-hides-your-ip-but-your-dns-lookups-still-happen-at-home-one-letter-fixes-it</link><guid isPermaLink="true">https://buyproxyorg.hashnode.dev/your-proxy-hides-your-ip-but-your-dns-lookups-still-happen-at-home-one-letter-fixes-it</guid><category><![CDATA[networking]]></category><category><![CDATA[Python]]></category><category><![CDATA[web scraping]]></category><category><![CDATA[debugging]]></category><dc:creator><![CDATA[BuyProxy]]></dc:creator><pubDate>Tue, 17 Nov 2026 17:44:07 GMT</pubDate><content:encoded><![CDATA[<p>You've set up a SOCKS5 proxy and it works. An IP checker shows the proxy's IP, not yours. And yet one of these keeps happening:</p>
<ul>
<li>curl says <code>Could not resolve host</code> for a hostname the proxy can reach fine.</li>
<li>The same proxy URL works from Python and fails from curl with <code>Can't complete SOCKS5 connection</code>.</li>
<li>Every hostname you open is still looked up by your own machine, through whatever DNS resolver your network hands you.</li>
</ul>
<p>In all three, the proxy URL starts with <code>socks5://</code>. Change it to <code>socks5h://</code> and all three went away in our tests.</p>
<h2>The fix</h2>
<p>curl:</p>
<pre><code class="language-bash">curl -x socks5h://user:pass@host:port https://example.com/
# the same thing as a flag
curl --socks5-hostname host:port https://example.com/
# or for every curl call in this shell
export ALL_PROXY=socks5h://user:pass@host:port
</code></pre>
<p><code>--socks5</code> and <code>-x socks5://</code> are the versions that resolve on your machine.</p>
<p>Python requests needs the SOCKS extra (<code>pip install "requests[socks]"</code>), then:</p>
<pre><code class="language-python">proxy = "socks5h://user:pass@host:port"
requests.get(url, proxies={"http": proxy, "https": proxy})
</code></pre>
<p>Not sure which mode curl is using? Add <code>-v</code>. It prints <code>(locally resolved)</code> when your machine did the lookup and <code>(remotely resolved)</code> when the proxy did.</p>
<h2>What the h changes</h2>
<p>When a client asks a SOCKS5 proxy to connect somewhere, it sends either an address or a hostname. With <code>socks5://</code> your machine looks up the name first and sends the proxy an IP. With <code>socks5h://</code> it sends the name as is and the proxy does the lookup on its side.</p>
<p>That's the usual one-line explanation. We wanted to watch it happen, so we logged both ends.</p>
<h2>The test</h2>
<p>Everything ran on one Mac (macOS 26), on localhost, with no third party involved: curl 8.7.1, Python 3.9.6, requests 2.32.5 with PySocks 1.7.1.</p>
<p>Three small scripts:</p>
<ul>
<li><code>target.py</code>, a "website" that only listens on IPv4, at <code>127.0.0.1:8778</code></li>
<li><code>socks_logger.py</code>, a SOCKS5 proxy at <code>127.0.0.1:1080</code> that prints what each client asks it to connect to. It also knows one name the laptop can't resolve, <code>intranet.test</code>, standing in for an internal hostname that only exists on the proxy's side.</li>
<li><code>lookups.py</code>, which logs every DNS lookup Python makes while requests talks to the proxy</li>
</ul>
<h4><code>target.py</code></h4>
<pre><code class="language-python"># target.py: the "website", on localhost only
from http.server import BaseHTTPRequestHandler, HTTPServer

class T(BaseHTTPRequestHandler):
    def do_GET(self):
        body = f"hello, Host header was {self.headers['Host']}\n".encode()
        self.send_response(200)
        self.send_header("Content-Length", str(len(body)))
        self.end_headers()
        self.wfile.write(body)

    def log_message(self, *a):
        pass

HTTPServer(("127.0.0.1", 8778), T).serve_forever()
</code></pre>
<h4><code>socks_logger.py</code></h4>
<pre><code class="language-python"># socks_logger.py: a tiny SOCKS5 proxy (no auth) that prints what each client asks it to connect to
import socket, struct, threading

# Names only the proxy side can resolve, like an internal hostname or a region-specific DNS answer
PROXY_SIDE_HOSTS = {"intranet.test": "127.0.0.1"}

def recv_exact(sock, n):
    data = b""
    while len(data) &lt; n:
        chunk = sock.recv(n - len(data))
        if not chunk:
            raise ConnectionError("client closed")
        data += chunk
    return data

def pipe(src, dst):
    try:
        while (data := src.recv(65536)):
            dst.sendall(data)
    except OSError:
        pass
    finally:
        for s in (src, dst):
            try:
                s.shutdown(socket.SHUT_RDWR)
            except OSError:
                pass

def handle(client):
    _, n_methods = recv_exact(client, 2)
    recv_exact(client, n_methods)
    client.sendall(b"\x05\x00")                      # no authentication
    _, _, _, atyp = recv_exact(client, 4)
    if atyp == 1:
        kind, addr = "IPv4", socket.inet_ntoa(recv_exact(client, 4))
    elif atyp == 3:
        kind, addr = "hostname", recv_exact(client, recv_exact(client, 1)[0]).decode()
    else:
        kind, addr = "IPv6", socket.inet_ntop(socket.AF_INET6, recv_exact(client, 16))
    port = struct.unpack("&gt;H", recv_exact(client, 2))[0]
    print(f"proxy got: {kind:&lt;8} {addr}:{port}", flush=True)
    try:
        upstream = socket.create_connection((PROXY_SIDE_HOSTS.get(addr, addr), port), timeout=5)
    except OSError:
        client.sendall(b"\x05\x04\x00\x01" + b"\x00" * 6)   # host unreachable
        client.close()
        return
    client.sendall(b"\x05\x00\x00\x01" + b"\x00" * 6)
    threading.Thread(target=pipe, args=(client, upstream), daemon=True).start()
    pipe(upstream, client)

server = socket.socket()
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.bind(("127.0.0.1", 1080))
server.listen()
while True:
    conn, _ = server.accept()
    threading.Thread(target=handle, args=(conn,), daemon=True).start()
</code></pre>
<h4><code>lookups.py</code></h4>
<pre><code class="language-python"># lookups.py: log every DNS lookup Python makes while requests talks to the proxy
import socket, sys, warnings
warnings.filterwarnings("ignore")

real_getaddrinfo = socket.getaddrinfo
def logged_getaddrinfo(host, *args, **kwargs):
    print(f"  local DNS lookup: {host}")
    return real_getaddrinfo(host, *args, **kwargs)
socket.getaddrinfo = logged_getaddrinfo

import requests
scheme, url = sys.argv[1], sys.argv[2]
proxy = f"{scheme}://127.0.0.1:1080"
try:
    r = requests.get(url, proxies={"http": proxy, "https": proxy}, timeout=5)
    print(f"  result: {r.status_code}")
except Exception as e:
    print(f"  result: {type(e).__name__}")
</code></pre>
<h2>What the proxy received</h2>
<p>We asked for two hosts with each client and each scheme: <code>localhost</code>, which both sides can resolve, and <code>intranet.test</code>, which only the proxy can.</p>
<table>
<thead>
<tr>
<th>Client</th>
<th>Scheme</th>
<th>Host</th>
<th>Proxy received</th>
<th>Result</th>
</tr>
</thead>
<tbody><tr>
<td>curl</td>
<td><code>socks5://</code></td>
<td>localhost</td>
<td>IPv6 <code>::1:8778</code></td>
<td>failed: <code>Can't complete SOCKS5 connection to localhost. (4)</code></td>
</tr>
<tr>
<td>curl</td>
<td><code>socks5h://</code></td>
<td>localhost</td>
<td>hostname <code>localhost:8778</code></td>
<td>200</td>
</tr>
<tr>
<td>curl</td>
<td><code>socks5://</code></td>
<td>intranet.test</td>
<td>no CONNECT at all</td>
<td><code>Could not resolve host: intranet.test</code></td>
</tr>
<tr>
<td>curl</td>
<td><code>socks5h://</code></td>
<td>intranet.test</td>
<td>hostname <code>intranet.test:8778</code></td>
<td>200</td>
</tr>
<tr>
<td>requests</td>
<td><code>socks5://</code></td>
<td>localhost</td>
<td>IPv4 <code>127.0.0.1:8778</code></td>
<td>200</td>
</tr>
<tr>
<td>requests</td>
<td><code>socks5h://</code></td>
<td>localhost</td>
<td>hostname <code>localhost:8778</code></td>
<td>200</td>
</tr>
<tr>
<td>requests</td>
<td><code>socks5://</code></td>
<td>intranet.test</td>
<td>no CONNECT at all</td>
<td><code>ConnectionError</code>: <code>[Errno 8] nodename nor servname provided, or not known</code></td>
</tr>
<tr>
<td>requests</td>
<td><code>socks5h://</code></td>
<td>intranet.test</td>
<td>hostname <code>intranet.test:8778</code></td>
<td>200</td>
</tr>
</tbody></table>
<p>And the DNS lookups Python made on the test machine during the same requests:</p>
<table>
<thead>
<tr>
<th>Scheme</th>
<th>Host</th>
<th>Lookups on the test machine</th>
</tr>
</thead>
<tbody><tr>
<td><code>socks5://</code></td>
<td>localhost</td>
<td><code>127.0.0.1</code>, <code>localhost</code></td>
</tr>
<tr>
<td><code>socks5://</code></td>
<td>intranet.test</td>
<td><code>127.0.0.1</code>, <code>intranet.test</code></td>
</tr>
<tr>
<td><code>socks5h://</code></td>
<td>localhost</td>
<td><code>127.0.0.1</code></td>
</tr>
<tr>
<td><code>socks5h://</code></td>
<td>intranet.test</td>
<td><code>127.0.0.1</code></td>
</tr>
</tbody></table>
<p>The <code>127.0.0.1</code> lookup is the proxy's own address, which the client needs either way. The target's name only shows up with <code>socks5://</code>.</p>
<h2>Why each problem happens</h2>
<h3>"Could not resolve host" through a working proxy</h3>
<p>With <code>socks5://</code>, your machine has to resolve the name before the proxy hears anything about it. If the name only exists on the proxy's side, say an internal hostname you reach through an SSH tunnel (<code>ssh -D</code>) or an office proxy, your lookup fails and the request never gets to the proxy. Our logger saw both clients open a connection, do the SOCKS greeting, and hang up before sending CONNECT.</p>
<h3>Works in Python, fails in curl</h3>
<p>Same name, different address. For <code>localhost</code>, curl handed the proxy <code>::1</code> and Python handed it <code>127.0.0.1</code>. On this Mac, Python's <code>getaddrinfo("localhost")</code> lists <code>127.0.0.1</code> first, and curl went with the IPv6 one anyway. Our target only listened on IPv4, so curl's request failed with SOCKS reply code 4, "host unreachable". With <code>socks5h://</code>, both clients sent the name and the proxy picked an address that worked. The same thing can happen on a real proxy when your machine picks an address the proxy's network can't reach.</p>
<h3>DNS lookups still happen at home</h3>
<p>With <code>socks5://</code>, every hostname is looked up by your machine, so the query goes to whatever resolver your network uses, often your ISP's or your router's, even though the traffic itself goes through the proxy. Sites behind a CDN also often choose which server to send you to based on where the DNS query came from, so you can end up connecting through a proxy in one country to a server picked for another. With <code>socks5h://</code> the proxy does the lookup.</p>
<h2>What this doesn't tell you</h2>
<ul>
<li>It's two clients on one Mac. Other libraries and tools handle SOCKS differently, and some only support one of the two modes.</li>
<li>The IPv6 result comes from this machine's resolver and curl's choice of address. A real proxy with working IPv6 wouldn't have failed the way our IPv4-only target did.</li>
<li>We logged lookups inside Python, not on the network, so we didn't see which resolver answered them. The ISP and CDN points describe how <code>socks5://</code> works; we didn't record them in this test.</li>
</ul>
<hr />
<p><em>Originally published on <a href="https://dev.to/ishantsinghdev/your-proxy-hides-your-ip-but-your-dns-lookups-still-happen-at-home-one-letter-fixes-it-1mdi">DEV</a> by Ishant Singh, Head of Operations at BuyProxy. BuyProxy's connection snippets use <code>socks5h://</code> for the reasons above. AI disclosure: Claude drafted this post and ran the tests on our machine, and every request stayed on localhost.</em></p>
]]></content:encoded></item></channel></rss>