[BUG] Claude Code fails with ESERVFAIL on HPC systems with DNS infrastructure issues
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Summary
Claude Code CLI fails to authenticate and install on HPC systems when the primary DNS nameserver returns ESERVFAIL errors, even though secondary DNS servers can resolve the domains successfully. The CLI does not gracefully fall back to secondary DNS servers.
Environment
Claude Code Version: 2.1.191, 2.1.196
Platform: Linux (HPC cluster - Ubuntu-based)
OS: Linux
Node Examples: hpc-wfly-a002, hpc-enri-i006
Network: Behind institutional firewall with multiple DNS servers
Issue Description
When attempting to use Claude Code on an HPC system with DNS infrastructure issues, the CLI fails with ESERVFAIL errors even though:
Secondary DNS servers work fine
Other tools (curl, wget, nslookup) can resolve Anthropic domains
The connection to Anthropic's servers is not blocked
During installation:
Failed to fetch version from https://downloads.claude.ai/claude-code-releases/latest after 3 attempt(s): getaddrinfo ESERVFAIL downloads.claude.ai
Diagnostic Output
bash$ nslookup api.anthropic.com
;; Got SERVFAIL reply from 192.168.222.253, trying next server
Server: 155.69.3.8
Address: 155.69.3.8#53
Non-authoritative answer:
Name: api.anthropic.com
Address: 160.79.104.10
;; Got SERVFAIL reply from 192.168.222.253, trying next server
Note: DNS resolution succeeds via secondary server, but Claude Code still fails.
bash$ curl -I https://api.anthropic.com
HTTP/2 404 # Connection works, but returns 404 (likely auth failure)
Additional Context
This issue affects institutional HPC systems where DNS infrastructure has multiple nameservers. Claude Code fails when the primary nameserver fails, even though secondary nameservers work fine. Other standard tools handle this gracefully.
What Should Happen?
Expected Behavior
Claude Code should work when secondary DNS servers are available and functional, even if the primary DNS server fails. Standard tools like curl and wget handle this automatically.
Actual Behavior
Claude Code fails with ESERVFAIL and exits immediately, even though DNS resolution succeeds via secondary servers.
Error Messages/Logs
Error Messages
Unable to connect to Anthropic services
Failed to connect to api.anthropic.com: ESERVFAIL
Steps to Reproduce
On an HPC system with a primary DNS server that fails for specific domains
Run claude or curl -fsSL https://claude.ai/install.sh | bash
Observe ESERVFAIL errors for api.anthropic.com and downloads.claude.ai
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.196
Platform
Anthropic API
Operating System
Other Linux
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
Showing cached comments. Read the full discussion on GitHub ↗
4 Comments
Found 2 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Hitting this on an HPC login node (Rocky/RHEL-family, glibc). Same getaddrinfo ESERVFAIL on both downloads.claude.ai (install) and api.anthropic.com (runtime).
Root cause (in my case)
Not an IP block. The site's primary nameserver is intermittently failing to resolve Anthropic domains, and glibc queries it first and doesn't reliably fail over to the secondaries. So resolution is a coin flip — sometimes it works, sometimes ESERVFAIL.
The secondaries resolve fine every time:
$ dig +short downloads.claude.ai @<primary>
# (empty / SERVFAIL)
$ dig +short downloads.claude.ai @<secondary>
35.190.46.17
$ dig +short api.anthropic.com @<secondary>
160.79.104.10
/etc/resolv.conf was byte-identical to a colleague whose install worked, which is what pointed to intermittent primary + failover behaviour rather than config.
What did NOT work
curl -fsSL https://claude.ai/install.sh | bash — the script's internal curl calls use the system resolver, so pinning DNS on the outer pipe doesn't propagate.
--resolve downloads.claude.ai:443:<IP> on the outer curl — same reason; child calls ignore it.
claude install --force — the native binary does its own version fetch against downloads.claude.ai at install time; --force does not skip it, so it still ESERVFAILs.
What worked (root-free)
bashBASE="https://downloads.claude.ai/claude-code-releases"
DIR="$HOME/.claude/downloads"; mkdir -p "$DIR"
IP=$(dig +short downloads.claude.ai @<secondary> A | grep -E '^[0-9]' | head -1)
R="--resolve downloads.claude.ai:443:$IP"
arch=x64 # or arm64
platform="linux-$arch" # add -musl if on musl
V=$(curl -fsSL $R "$BASE/latest")
BIN="$DIR/claude-$V-$platform"
curl -fsSL $R -o "$BIN" "$BASE/$V/$platform/claude"
verify against $BASE/$V/manifest.json checksum, then:
chmod +x "$BIN"
bashmkdir -p ~/.local/bin
cp "$BIN" ~/.local/bin/claude && chmod +x ~/.local/bin/claude
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
echo 'export DISABLE_AUTOUPDATER=1' >> ~/.bashrc
bashprintf 'nameserver <secondary1>\nnameserver <secondary2>\n' > ~/.claude-resolv.conf
unshare --mount --map-root-user bash -c \
'mount --bind "$HOME/.claude-resolv.conf" /etc/resolv.conf; exec claude "$@"' bash "$@"
(Requires unprivileged user namespaces to be enabled; some clusters disable them.)
Suggestions
Two things would make this much less painful for locked-down / HPC environments:
Have claude install (and the startup update check) honor a standard proxy/DNS override, or at least degrade gracefully when downloads.claude.ai is unreachable but api.anthropic.com is fine — right now a flaky downloads resolver blocks install entirely even though the binary only needs the API host to actually run.
Document an offline/air-gapped install path (download binary + manifest checksum, drop on PATH, DISABLE_AUTOUPDATER=1) — that's effectively what worked here.
Thanks for the detailed investigation and workaround.
One possible improvement might be to make the installer more resilient when
downloads.claude.aicannot be resolved butapi.anthropic.comis still reachable. Instead of immediately failing withESERVFAIL, the installer could:This could improve the installation experience on institutional and enterprise Linux environments where intermittent DNS issues are outside the user's control.
Reproduced this outside HPC, on a plain home network — so this isn't specific to institutional DNS infrastructure.
Environment
192.168.1.1) in/etc/resolv.conf— the PVE default of inheriting host DNSSymptom
claude loginfails immediately with:So this affects the OAuth login flow too, not just the installer.
Why diagnostics look healthy while the CLI fails
The router SERVFAILs intermittently. Every manual check passed —
nslookup,curl, and evengetent ahosts platform.claude.com(which uses glibcgetaddrinfo, the same path Node goes through) — because those paths retry or a subsequent attempt succeeds. Claude Code appears to exit on the first SERVFAIL with no retry, and with a single configured nameserver there is no fallback at all, so the failure is hard while everything around it looks fine.Workaround (consistent with what others found: only the first nameserver matters)
Put a public resolver first, keep the local one as backup:
(or the equivalent
resolv.confedit). Login works reliably since.A single retry on SERVFAIL — or falling back to the next configured nameserver like the rest of the system stack does — would make this class of failure disappear on both consumer and institutional networks.