---
title: "Connect timeouts when a name has IPv6 addresses the host cannot reach | Proofline"
description: "When a name returns AAAA records and the host has an IPv6 address but no working IPv6 path, clients that try IPv6 first wait for it to fail before trying IPv4."
url: https://proofline.sh/learn/ipv6-aaaa-connect-timeouts/
---

[Learning center](/learn/)

# Connect timeouts when a name has IPv6 addresses the host cannot reach

When a name returns AAAA records and the host has an IPv6 address but no working IPv6 path, clients that try IPv6 first wait for it to fail before trying IPv4. Some clients race the two families and lose only a fraction of a second; others try IPv6 until the connect timeout and then give up. Compare curl -4 with curl -6 from the failing host, and read its IPv6 routes, before you blame the dependency.

Network outages The Proofline team November 23, 2026 5 min read

## The symptom

Calls to a dependency take seconds longer than they should, or fail with connect timeouts, from some hosts only:

-   `curl https://api.example.com` hangs for a while and then succeeds; `curl -4` is instant.
-   The dependency recently added AAAA records, or moved to a provider or load balancer that publishes them.
-   The failing hosts are in a subnet or cluster where IPv6 was half set up: addresses assigned, no default route, or a firewall that drops IPv6.

The address the client connects to depends on the sorted list the resolver returned and on the client's connection strategy, so two services on the same host can behave differently.

## Why IPv6 goes first

glibc's `getaddrinfo` sorts its results with the RFC 3484 rules, whose default precedence table ranks IPv6 (`::/0`, precedence 40) above IPv4-mapped addresses (`::ffff:0:0/96`, precedence 10). RFC 6724, which replaced RFC 3484, keeps IPv6 ahead of IPv4 in its default policy table. A client that walks the list in order tries the IPv6 addresses first. [gai.conf(5)](https://man7.org/linux/man-pages/man5/gai.conf.5.html) · [RFC 6724](https://www.rfc-editor.org/rfc/rfc6724)

With its default hints, `getaddrinfo` uses `AI_ADDRCONFIG`, which returns IPv6 addresses only if the local system has at least one IPv6 address configured, not counting loopback. A host with an IPv6 address and no IPv6 route still gets AAAA results. [getaddrinfo(3)](https://man7.org/linux/man-pages/man3/getaddrinfo.3.html)

What happens next depends on the client:

| Client | Behavior |
| --- | --- |
| Happy Eyeballs (RFC 8305) | Starts IPv6, then IPv4 after a short delay; recommended 250 ms |
| curl | Gives IPv6 a 200 ms head start by default |
| Go `net.Dialer` | Starts the other family after `FallbackDelay`, 300 ms by default |
| Node.js `net` | `autoSelectFamily` on by default since v20 |
| Java | Prefers IPv4 unless `java.net.preferIPv6Addresses` is set |
| Plain sequential connect | Tries each address in order, each up to the connect timeout |

[RFC 8305](https://www.rfc-editor.org/rfc/rfc8305) · [curl manual](https://curl.se/docs/manpage.html) · [Go net.Dialer](https://pkg.go.dev/net) · [Node.js net](https://nodejs.org/api/net.html) · [Java networking properties](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/net/doc-files/net-properties.html)

A client with Happy Eyeballs usually hides the broken IPv6 path at a small cost. A sequential client with a 10-second connect timeout and two AAAA records spends 20 seconds before it reaches the first IPv4 address, which in practice means the request times out first.

## Observe without changing anything

From the failing host or container, see what the name returns and in which order the system sorts it. `getent ahosts` prints the addresses in the order `getaddrinfo` returns them. [getent(1)](https://man7.org/linux/man-pages/man1/getent.1.html)

```
dig +short NAME A
dig +short NAME AAAA
getent ahosts NAME
```

Then read the host's IPv6 configuration, and ask the kernel which route it would use for one of the AAAA addresses. [ip-route(8)](https://man7.org/linux/man-pages/man8/ip-route.8.html)

```
ip -6 addr show
ip -6 route show
ip route get 2001:db8:10::25
```

Finally, time the connection per family. `-4` and `-6` restrict curl to one family, and `--connect-timeout` bounds the connection phase. [curl manual](https://curl.se/docs/manpage.html)

```
curl -4 -sv -o /dev/null --connect-timeout 5 -w '%{time_connect}\n' https://NAME/
curl -6 -sv -o /dev/null --connect-timeout 5 -w '%{time_connect}\n' https://NAME/
```

## Read the result

| `curl -6` | `curl -4` | IPv6 route | Points to |
| --- | --- | --- | --- |
| Times out | Fast | None for the address | Host has IPv6 addresses but no route; clients that prefer IPv6 stall |
| Times out | Fast | Present | IPv6 blocked or broken on the path or at the dependency |
| Fast | Fast | Present | Not IPv6; look at the client's own timeouts or the dependency |
| Times out | Times out | Any | Not an address-family problem; see refused vs timeout |

If `ip route get` returns an error such as network unreachable, the client should fail fast rather than time out, and a quick failure followed by IPv4 is harmless. Long stalls come from a route that exists, such as a default route, where packets then disappear. [Connection refused or timeout](/learn/connection-refused-vs-timeout/)

## A worked example

This example is illustrative. On Monday, the payments provider adds AAAA records for `api.payments.example.com`: 2001:db8:10::25 and 2001:db8:10::26, beside 203.0.113.25. The `checkout` service runs on hosts in a dual-stack subnet whose route table has an IPv6 default route to a gateway that the network team has not finished configuring.

From a `checkout` host:

| Check | Result |
| --- | --- |
| `getent ahosts` | the two IPv6 addresses first, then 203.0.113.25 |
| `ip route get 2001:db8:10::25` | via the IPv6 default route |
| `curl -6 --connect-timeout 5` | timed out after 5 s |
| `curl -4 --connect-timeout 5` | connected in 22 ms |

The `checkout` service uses an HTTP client that connects to addresses in order with a 10-second connect timeout. Every request now tries both IPv6 addresses before IPv4 and hits the request deadline first. The `orders` service on the same hosts is written in Go and sees only an extra 300 ms per new connection. The provider is healthy over IPv4 and the path is the problem.

In a second case, `curl -6` connects in 25 ms and `curl -4` in 21 ms, and the service still times out. IPv6 is not the cause; compare with the dependency's own latency next. [Client or server latency](/learn/dependency-latency-client-or-server/)

## Limits

curl runs its own connection logic. A successful `curl -4` says the IPv4 path works, not how your client orders and retries addresses; read the client library's documentation for its strategy and timeouts.

The sort order is configurable. In `/etc/gai.conf`, a `precedence` line that ranks `::ffff:0:0/96` above `::/0` makes glibc sort IPv4 first, but any single `precedence` line replaces the whole default table, so copy the defaults you keep. That is a host change, not a diagnosis. Other runtimes, such as Go's pure resolver and Node.js with its default `verbatim` order, apply their own ordering. [Node.js dns result order](https://nodejs.org/api/dns.html)

For lookups that fail outright rather than connect slowly, see [NXDOMAIN, SERVFAIL or no answer](/learn/dns-nxdomain-servfail-timeout/). For the method across dependency layers, see [runtime dependency failures](/learn/runtime-dependency-failures/).

## Questions

### Why does curl hang before connecting when the site works?

The name has AAAA records and your host has an IPv6 address but no working IPv6 path. curl tries IPv6 first and falls back to IPv4 after its Happy Eyeballs delay or the connect attempt fails. Compare `curl -4` and `curl -6` to confirm.

### Does removing the AAAA lookup fix it?

It hides it. glibc's `no-aaaa` option in `resolv.conf` (since glibc 2.36) suppresses AAAA queries, and an IPv4 preference in `gai.conf` reorders results. Fixing or removing the host's broken IPv6 route addresses the cause.

### What is Happy Eyeballs?

An algorithm, specified in RFC 8305, that starts a connection over IPv6 and, if it has not succeeded after a short delay, starts one over IPv4 in parallel, keeping whichever connects first. It makes a broken IPv6 path cost milliseconds instead of a full timeout.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Connection refused or timed out: what each error tells you](/learn/connection-refused-vs-timeout/)
    
    Network outages The Proofline team November 23, 2026 6 min read
    
-   ### [Dependency slow for the client but fast on the server](/learn/dependency-latency-client-or-server/)
    
    Network outages The Proofline team November 23, 2026 6 min read
