[BUG] Persistent "Unable to connect to API (ECONNRESET)" — survives network change, reinstall, and reboot (macOS, v2.1.212, Claude Pro)
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?
Title: Persistent "Unable to connect to API (ECONNRESET)" — survives network change, reinstall, and reboot (macOS, v2.1.212, Claude Pro)
Environment
- Claude Code version: 2.1.212
- OS: macOS
- Auth: Claude Pro subscription (not API key)
- Terminal: Apple Terminal
Summary
Claude Code intermittently fails with "Unable to connect to API (ECONNRESET)" and retries through all attempts before failing. The error is intermittent — a prompt may succeed, then the next one fails, then it works again. First noticed after leaving a Claude Code session open and idle for an extended period; it has recurred repeatedly since, even in fresh sessions.
What I've ruled out
- Not a service outage — confirmed via status.claude.com, all systems operational at time of failures
- Not usage limits — /status shows normal, and the pattern (works, fails, works) doesn't match a hard limit
- Not a stray API key — no ANTHROPIC_API_KEY set
- Not Tailscale/VPN — fully uninstalled Tailscale, issue persisted
- Not network-specific — reproduced on home broadband AND a mobile hotspot (different network entirely)
- Not stale local state — fully uninstalled and reinstalled Claude Code, restarted the process multiple times, and rebooted the machine; issue persisted through all of this
- curl -I https://api.anthropic.com consistently returns a clean HTTP/2 404 with proper Cloudflare headers, even at the moment of failure — so basic reachability to the API host is fine
- Not an unusual/corporate CA cert — system keychain only has default macOS certs (com.apple.systemdefault, com.apple.kerberos.kdc, localhost, Apple WWDR) after removing an old mkcert dev certificate, which had no effect on the issue
Debug log excerpts
On startup:
CA certs: stores=bundled,system, extraCertsPath=undefined
CA certs: Loaded 120 bundled root certificates
CA certs: Loaded 7 system CA certificates
mTLS: Creating HTTPS agent with custom certificates
Failure during use:
[API:timing] dispatching to firstParty model=claude-sonnet-5
[API REQUEST] /v1/messages x-client-request-id=...
[ERROR] API error (attempt 6/11): undefined Connection error.
Failure even at idle/startup (before any prompt sent):
[ERROR] 1P event logging: 47 events failed to export (code=ECONNRESET, socket hang up)
[ERROR] [3P telemetry] OTEL diag error: {"message":"Failed to export 47 events (code=ECONNRESET, socket hang up)", ...}
Expected behavior
Claude Code should maintain or cleanly re-establish a connection to api.anthropic.com without requiring the user to kill and restart the process repeatedly, especially given curl to the same host succeeds at the same time.
Additional notes
Happy to provide the full debug logs if useful. This has been reproduced across two different networks and after a clean reinstall, so I don't believe this is an environment-specific config issue on my end.
What Should Happen?
8a5c1d0a-20d1-41f8-b60f-dc8350dd3019.txt
93fa6a7c-93f5-4469-a05a-b79ca4dde59a.txt
bee31862-62e7-4bf0-8f77-fb2acd9b3368.txt
Error Messages/Logs
Steps to Reproduce
The issue persists after uninstall / reinstall, computer restarts, removing VPN's and different networks.
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.212
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_