CI "Temporary failure in name resolution" - Fix EAI_AGAIN
The resolver returned EAI_AGAIN - "temporary failure in name resolution". The word *temporary* is the key: the DNS lookup did not get an authoritative answer, but it is the kind of failure that typically clears on retry.
What this error means
A network call fails with Temporary failure in name resolution or getaddrinfo EAI_AGAIN. It is intermittent - re-running usually succeeds - which distinguishes it from a permanent EAI_NONAME / "host not found".
ping: github.com: Temporary failure in name resolution
# or
Error: getaddrinfo EAI_AGAIN registry.npmjs.orgCommon causes
Upstream DNS timed out or was unreachable
The resolver could not reach the upstream DNS server in time. EAI_AGAIN signals a soft, retryable failure rather than a definitive "no such host".
DNS service not ready at job start
On a freshly booted runner or container, the resolver or network may not be fully up for the first few requests, producing transient EAI_AGAIN early in the job.
How to fix it
Retry with backoff
Because EAI_AGAIN is explicitly temporary, a short retry usually succeeds.
for i in 1 2 3; do
curl -fsSL https://registry.npmjs.org/ && break
sleep $((i*2))
doneStabilize resolution if it recurs
- Check
/etc/resolv.confhas a reachable nameserver. - Add a brief warm-up/wait for the network before the first DNS-dependent step.
- Point at a reliable resolver (e.g.
1.1.1.1,8.8.8.8) if the default is flaky.
How to prevent it
- Add bounded retries around DNS-dependent steps.
- Ensure the network/resolver is ready before the first call.
- Use a dependable resolver and cache/mirror where possible.