An IPv6-only target is a server that publishes only an AAAA record in DNS, so it can be reached only at an IPv6 address. When you use a proxy, the target is reached by the proxy's egress connection, not by yours. A proxy with IPv4-only egress has no route to that target and rejects the request with an error. The trap is that the error looks like a proxy failure. This post covers the symptoms, who resolves DNS, how to check the target and how to fix it.
The two legs of the connection
A proxied request has two separate connections. The first runs from you to the proxy, the second from the proxy to the target. Which address family the target accepts matters only for the second leg.
That is why IPv6 on your own machine doesn't change the result. You can connect to the proxy over IPv4 and still exit to an IPv6 target. The reverse also holds: even if you have IPv6, the target is dialled only over IPv4 when the proxy's egress is IPv4.
| Target's DNS record | IPv4 egress proxy | IPv6 egress proxy | Dual-stack egress |
|---|---|---|---|
| A only (IPv4) | ✓ | ✗ | ✓ over IPv4 |
| A + AAAA (dual-stack) | ✓ over IPv4 | ✓ over IPv6 | ✓ |
| AAAA only (IPv6) | ✗ | ✓ | ✓ over IPv6 |
The last row is the subject of this post. There is no path over IPv4 to a target that only has an AAAA record. No setting, retry or other IPv4 address changes that.
Symptoms and error messages
A proxy with IPv4 egress loses an IPv6-only target in one of two places: while resolving the name or while connecting. Most of the time it fails at the first step. The proxy looks for an IPv4 address for the name, finds none and never attempts the connection.
An HTTP proxy reports this with a status code. Which code you get depends on the proxy software. 502 is common, 503 or 504 also occur. We wrote our test proxy to return 502 in this case. Here is how the clients reacted to that answer:
| Client and scheme | Error we saw |
|---|---|
curl, http:// proxy | curl: (7) CONNECT tunnel failed, response 502 |
curl, socks5h:// | curl: (97) cannot complete SOCKS5 connection to ipv6.google.com. (4) |
curl, socks5:// | curl: (6) Could not resolve host: ipv6.google.com |
Requests, http:// proxy | ProxyError('Unable to connect to proxy', OSError('Tunnel connection failed: 502 Bad Gateway')) |
Requests, socks5h:// | NewConnectionError(… 0x04: Host unreachable) |
The trailing number in the SOCKS5 errors is the proxy's reply code. (4) means "host unreachable", (3) means "network unreachable". With HTTP, the proxy answers before it opens the CONNECT tunnel, so the target server is never touched. The general meaning of 502 and who sends it are covered in our 502 Bad Gateway post.
If the same proxy works fine with dual-stack or IPv4 targets and the error appears only on certain domains, the target's address family is the first suspect.
Who resolves DNS
Who resolves the name decides what the error message looks like. With an HTTP proxy and the socks5h:// scheme, the proxy resolves the name. With socks5://, your machine resolves it and sends the proxy an IP address.
When the proxy resolves the name, the result depends on the proxy's network. A proxy with IPv4 egress either never asks for the AAAA record or can't use it. In our test, the HTTP proxy returned 502 and the SOCKS5 server returned "host unreachable".
When you resolve the name, there are two possible outcomes:
- If your machine has no IPv6, the operating system may not hand you the AAAA record. The request never reaches the proxy. In our test, curl stopped with
(6) Could not resolve host. The error looks like a DNS problem, yet the record exists. - If your machine has IPv6, the client sends the proxy an IPv6 address. A proxy with IPv4 egress can't connect to it. In a test where we passed the IPv6 address by hand, the SOCKS5 server returned
(3)"network unreachable".
We cover the general difference between the two schemes and the DNS leak side in our SOCKS5 vs SOCKS5H post. For IPv6 the rule is simple: use socks5h://, so both resolution and connection happen on the proxy's network.
Dual-stack targets
A dual-stack target is a server that publishes both an A and an AAAA record in DNS. A proxy with IPv4 egress connects to it through the A record and has no trouble. In our test, a request to localhost, which has both records, went through the proxy over 127.0.0.1 and returned 200.
Most sites run either IPv4 only or dual-stack. IPv6-only targets are rarer: test subdomains, IPv6-specific API endpoints, some internal services and newly built infrastructure. That is why the problem usually shows up on a single domain and goes unnoticed.
There is one more trap. A site's main name can be dual-stack while one of its subdomains, such as api. or cdn., publishes only AAAA. Run the check on the exact domain the request goes to, not on the page.
Checking the target
You see which records a target publishes by asking DNS directly. Use dig on Linux and macOS, nslookup on Windows:
# Linux / macOS
dig A ipv6.google.com +short
dig AAAA ipv6.google.com +short
# Windows
nslookup -type=A ipv6.google.com
nslookup -type=AAAA ipv6.google.comIf the A query returns no address and the AAAA query does, the target is IPv6-only. In our test, the A query for ipv6.google.com returned only alias (CNAME) information, while the AAAA query returned an IPv6 address.
Don't rely on the local resolver for this check. Python's socket.getaddrinfo, Node's dns.lookup and ping use the operating system's resolver. On a machine without IPv6, that resolver can hide the AAAA record. In our test, dns.lookup returned ENOTFOUND for the same name, while dns.resolve6 returned the address.
If you check in code, pick a function that queries DNS directly. The Node.js example below looks at the target's records and tells you which egress to use:
import dns from "node:dns/promises";
// Asks DNS directly which records the target publishes
async function addressFamilies(host) {
const [a, aaaa] = await Promise.all([
dns.resolve4(host).catch(() => []),
dns.resolve6(host).catch(() => []),
]);
return { ipv4: a.length > 0, ipv6: aaaa.length > 0 };
}
const f = await addressFamilies("ipv6.google.com");
const plan = f.ipv4 ? "IPv4 egress" : f.ipv6 ? "IPv6 egress" : "no records";
console.log(f, "->", plan);
// { ipv4: false, ipv6: true } -> IPv6 egressIn this example a dual-stack target goes to IPv4 egress. These targets work with either egress, so you can change the order to suit your workload.
How to fix it
The lasting fix is to reach IPv6-only targets through a proxy with IPv6 egress. That is what the IPv6 Proxy plan is for. As long as the target publishes an AAAA record and answers over IPv6, the connection goes through.
In practice three steps are enough:
- Check the A and AAAA records once for every exact domain on your target list.
- Route the AAAA-only ones to IPv6 egress and the rest to IPv4 egress.
- Use
socks5h://or an HTTP proxy in the proxy URL, so the proxy resolves the name.
There is also something to avoid. Don't put the 502 or (4) error on your retry list. Even if the IPv4 egress changes, the target still has no IPv4 address, so the result stays the same. Treating this error as a temporary failure means sending the same request again and again for nothing.
The reverse case works the same way. A proxy with IPv6 egress can't reach a target that only has an A record and returns the same errors: 502, "host unreachable" or "network unreachable". Sites that publish only IPv4 are still common, so you'll run into this case more often.
Those targets need IPv4 Proxy. We cover the general difference between the two address families on the proxy side, and where to pick each one, in our IPv4 vs IPv6 Proxy post. In short, the two plans sit next to each other, not in place of each other.
Troubleshooting
If the proxy fails on a particular domain, work through this order:
- Try another target. If the proxy returns 200 on an IPv4 target, the credentials and port are right.
- Look at the target's records. If
nslookup -type=Ais empty and-type=AAAAis not, the problem is the address family. - Check the scheme. If you get
Could not resolve hostwithsocks5://, the name is being resolved on your machine. Trysocks5h://. - Read the error code. In curl,
(97)with a trailing(3)or(4)shows the failure is on the proxy's target leg. - Check the exact domain. If the page loads but the API request fails, look at the records of the API's subdomain separately.
How we tested
We ran the tests on 1 December 2026 on a Windows 11 machine with an IPv4-only internet connection. Versions: curl 8.22.0, Python 3.13.17, Requests 2.34.2, PySocks 1.7.1, urllib3 2.6.3, Node.js 24.22.2.
We wrote two local proxies in Python. One was an HTTP proxy with CONNECT support, the other a SOCKS5 server implementing RFC 1928 and RFC 1929. Both used the machine's own network, so they behaved like a proxy with IPv4 egress. The HTTP proxy was written to return 502 for a target it couldn't reach. The SOCKS5 server logged the incoming address type and the error.
As the IPv6-only target we used ipv6.google.com, which publishes only an AAAA record. The dual-stack target was a local HTTP server reached by the name localhost. We didn't test with an IPv6 egress proxy, because the test machine had no IPv6 connectivity.
The bottom line
If requests fail only on certain domains, check the target's A and AAAA records first. Use socks5h:// or an HTTP proxy in the proxy URL and route IPv6-only targets to IPv6 egress. Above all, don't try to fix this error with retries: if the target has no IPv4 address, every attempt ends in the same place.
Sources
- RFC 3596, DNS Extensions to Support IP Version 6, section 2: datatracker.ietf.org
- RFC 1928, SOCKS Protocol Version 5, sections 4-6: datatracker.ietf.org
- libcurl error codes,
CURLE_COULDNT_RESOLVE_HOST,CURLE_COULDNT_CONNECT,CURLE_PROXY: curl.se - Requests, Advanced Usage, SOCKS: requests.readthedocs.io
Frequently asked questions
Why can't I connect to an IPv6 site through a proxy?
Because the proxy's egress is most likely IPv4-only. The proxy connects to the target from its own egress address. If the target publishes only an AAAA record in DNS, there is no address to reach over IPv4. In that case the proxy returns an HTTP code such as 502 or a SOCKS5 "host unreachable" reply. The fix is to reach these targets through a proxy with IPv6 egress.
How do I tell if a site is IPv6-only?
Ask DNS for the A and AAAA records separately. Use nslookup -type=A and nslookup -type=AAAA on Windows, dig A and dig AAAA on Linux and macOS. If the A query returns no address and the AAAA query does, the site is IPv6-only. Don't trust ping or the browser, because on a machine without IPv6 the local resolver can hide the AAAA record.
Will enabling IPv6 on my own computer fix it?
No. The proxy opens the connection to the target, not your computer. Your IPv6 only affects the leg to the proxy. With socks5://, enabling IPv6 may let the name resolve. But a proxy with IPv4 egress still can't connect to that IPv6 address and returns "network unreachable". What decides the outcome is the address family of the proxy's egress.
Should I use socks5 or socks5h?
Use socks5h://. With this scheme the proxy resolves the domain name, so resolution and connection happen on the same network. socks5:// resolves the name on your machine. On a machine without IPv6, that can mean the AAAA record is never found and you get Could not resolve host. The error looks like a DNS problem and hides the real cause.
Does an IPv4 proxy cause problems with dual-stack sites?
No. A dual-stack site publishes both an A and an AAAA record in DNS. A proxy with IPv4 egress uses the A record and connects normally. The problem only appears with targets that have nothing but an AAAA record. Even so, a subdomain can be IPv6-only while the site's main name is dual-stack. Run the check on the exact name the request goes to.
Does retrying a 502 error help?
No, not in this case. The target has no IPv4 address, so a new IPv4 egress ends up with the same result. Retrying only makes sense for temporary errors. If the error keeps appearing on certain domains, check the target's DNS records first. If you see only AAAA, route the request to IPv6 egress and take it off your retry list.




