[BUG] Persistent intermittent ECONNRESET ("socket closed unexpectedly") on Claude Code — macOS, multi-day, recurring across sessions
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?
Persistent intermittent ECONNRESET on Claude Code, recurring across multiple days and many sessions. Connection resets mid-request with "The socket connection was closed unexpectedly" / "undefined Connection error" and no HTTP status. Auto-retry eventually lands, but individual turns hit long retry storms — e.g. one turn ran through 9 of 11 attempts over ~4 minutes before succeeding.
This is happening live as I write this, during an active long-running session, and the failures recur across /clear and brand-new sessions — so it is not tied to any single session's state or context.
I could not even file this report from within Claude Code. The in-app /bug / feedback submission itself failed with "Couldn't send feedback (couldn't reach the service)" — because it sends over the same connection that's resetting. That's partly why I'm filing here, and it's itself a data point: the resets are frequent enough to block the built-in bug reporter.
Sample x-client-request-ids (all from one affected session, ~19:12–19:16 UTC, 25 Jun 2026, for server-log lookup):
47271ce4-36bf-4cb9-8162-797e5ef13703
bea9bb7f-db14-4a1f-a1cc-989dcd62a668
1a39554a-3b0c-4836-a8af-83a5959fe7a7
a3b38731-7aa9-4aac-8ccd-865c6862a541
c80ef21f-0574-4987-a2e8-568b82fb1816
Environment / ruled out locally:
Claude Code 2.1.190+ (native install), macOS Tahoe (26), Apple Silicon, home WiFi, no VPN/proxy.
curl https://api.anthropic.com/v1/messages returns a clean HTTP/2 405 (full TLS 1.3 handshake, valid cert) — network/DNS/TLS all healthy. Cloudflare edge: Delhi (-DEL).
Full re-auth (logout/login) did not help. A background-server/CLI version mismatch was found and fixed (didn't resolve it). scutil --proxy clean, env | grep proxy empty, macOS firewall off. Confirmed identical failure in standalone Terminal (not just VS Code's integrated terminal). Plan usage at 0% (Max 20x) — not a quota issue.
Failures are worse on large-context turns and recur in clustered bursts across hours, consistent with server-side connection handling rather than a local fault.
Region: Delhi, IN. Started ~2 days ago with no local changes; this setup ran fine for months prior.
I've eliminated the local layers (network, TLS, auth, CLI/daemon version, proxy, firewall, editor, quota) — the request IDs above should let the API team trace the server-side cause directly.
What Should Happen?
Claude Code should connect to the API and complete each turn normally — the same way curl does from the same machine. Requests should not be reset mid-flight, and the built-in /bug reporter should be able to submit.
Error Messages/Logs
[ERROR] API error (attempt 9/11): undefined Connection error.
[ERROR] Connection error details: code=ECONNRESET, message=The socket connection was closed unexpectedly. For more information, pass `verbose: true` in the second argument to fetch()
Retry timing for one affected turn (single request, 9 attempts):
19:12:20 → 19:12:36 → 19:12:52 → 19:13:10 → 19:13:30 → 19:13:53 → 19:14:27 → 19:15:22 → 19:16:14 UTC
In-app feedback submission also failed:
"Couldn't send feedback (couldn't reach the service)."
Steps to Reproduce
This is an intermittent server-side connection failure, not tied to specific input — it reproduces on essentially any turn during an affected window:
- Run Claude Code normally on macOS (native install), home network, no VPN/proxy.
- Send any prompt during an affected window (occurs in clustered bursts across hours).
- The turn fails with ECONNRESET / "socket closed unexpectedly" and auto-retries with backoff.
- Larger-context turns fail more often and retry longer (observed: 9 of 11 attempts over ~4 minutes before one landed).
- Confirmed local environment is clean — see request IDs and diagnostics in the main description for server-side trace.
Note: not input-dependent. curl to the same endpoint succeeds with a clean HTTP/2 405 while Claude Code's streaming connection resets.
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
Unknown exact version — worked reliably until ~2 days ago (June 23–24, 2026); no local changes since. Likely server-side rather than a client version regression.
Claude Code Version
2.1.190
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
VS Code integrated terminal
Additional Information
Persists across /clear and brand-new sessions, so not session-state-related. Happening live during an active long-running session as of filing.
Local layers eliminated: network, DNS, TLS (curl returns clean HTTP/2 405), auth (full re-auth done), CLI/background-server version mismatch (found and fixed, didn't resolve), system proxy (scutil --proxy clean), shell proxy env (empty), macOS firewall (off), editor (fails in standalone Terminal too), quota (0% used on Max 20x).
Cloudflare edge: Delhi (-DEL). Region: Delhi, IN.
The x-client-request-ids in the main description are the key artifact for server-side log lookup.