[BUG] ECONNRESET 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?
❯ review recent code changes
⎿ API Error: Unable to connect to API (ECONNRESET)
What Should Happen?
claude code should work, claude in browser works fine.
anthropic should fix the issue.
Error Messages/Logs
Steps to Reproduce
debug mode shows this in llog:
2026-02-25T15:03:58.658Z [ERROR] Error: Error: 1P event logging: 14 events failed to export (code=ECONNRESET, The socket connection was closed unexpectedly. For more information, pass verbose: true in the second argument to fetch())
at queueFailedEvents (/$bunfs/root/claude:6410:2350)
at async doExport (/$bunfs/root/claude:6410:1257)
at processTicksAndRejections (native:7:39)
2026-02-25T15:03:58.659Z [ERROR] Error: Error: {"message":"Failed to export 14 events (code=ECONNRESET, The socket connection was closed unexpectedly. For more information, pass verbose: true in the second argument to fetch())","originalLine":"6410","originalColumn":"1409","line":"6410","column":"1409","sourceURL":"/$bunfs/root/claude","stack":"Error: Failed to export 14 events (code=ECONNRESET, The socket connection was closed unexpectedly. For more information, pass verbose: true in the second argument to fetch())\n at doExport (/$bunfs/root/claude:6410:1409)\n at processTicksAndRejections (native:7:39)","name":"Error"}
at error (/$bunfs/root/claude:2342:25028)
at <anonymous> (/$bunfs/root/claude:119:92467)
at U7D (/$bunfs/root/claude:119:93011)
at <anonymous> (/$bunfs/root/claude:120:17366)
at processTicksAndRejections (native:7:39)
2026-02-25T15:03:58.659Z [ERROR] [3P telemetry] OTEL diag error: {"message":"Failed to export 14 events (code=ECONNRESET, The socket connection was closed unexpectedly. For more information, pass verbose: true in the second argument to fetch())","originalLine":"6410","originalColumn":"1409","line":"6410","column":"1409","sourceURL":"/$bunfs/root/claude","stack":"Error: Failed to export 14 events (code=ECONNRESET, The socket connection was closed unexpectedly. For more information, pass verbose: true in the second argument to fetch())\n at doExport (/$bunfs/root/claude:6410:1409)\n at processTicksAndRejections (native:7:39)","name":"Error"}
2026-02-25T15:04:22.964Z [DEBUG] Fast mode unavailable: Fast mode has been disabled by your organization
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
claude --version 2.1.56 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
happens more and more, generally need to reboot computer to fix.
17 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
#27789 is specific to the API not claude code cli
https://github.com/anthropics/claude-code/issues/25382 show 403 in logs prior to ECONNRESET, which isn't the same
https://github.com/anthropics/claude-code/issues/5674 this one is also API related
I'm constantly getting this and it has happened for half a year now and basically all issues are automatically closed without any response from Anthropic. They are becoming the new GitHub, ignoring all problems with their software because everyone is using them anyway.
I never had a monthly $100 subscription and the company cares this little about their product, it's sad.
I'm getting these errors non-stop. I can only fix it by either killing the process (need to repeat constantly), or a full machine restart. Using VSCode w/ Claude
are you running docker also? my problem happened when docker was running and the fix was to set network MTU to 1492 instead of 1500. no issues for several weeks now
I had exactly the same issue, but after disabling IPv6 and switching to IPv4, it started working without any problems.
same issue here. Windows 11, latest Versions and Updates applied, either CLI or VSCode Extension
Claude Code — Persistent ECONNRESET Bug Report
Report date: 2026-05-09
Severity: High — most sessions are disrupted, many fail entirely after 11 retry attempts
Working directory of reproduction:
/Users/jasonc/tmp/econnresetdebug log
---
1. Executive summary
Claude Code's CLI repeatedly fails with
ECONNRESETwhen callinghttps://api.anthropic.com/v1/messages?beta=trueand the OTEL/1P telemetryendpoints. The user experiences this as: most chats fail outright, occasional
ones succeed, and even successful sessions are punctuated by long retry-backoff
stalls.
The critical observation: identical destinations from the same host using
curl/ping/tracerouteare fast and 100% reliable (4–6 ms RTT, no packetloss, TLS handshake ~15–20 ms, HTTP/2 negotiates cleanly). The failures only
occur from inside Claude Code's Bun-bundled runtime. The internal error string
—
"The socket connection was closed unexpectedly. For more information, pass— is a Bun fetch–specificverbose: true in the second argument to fetch()"
error message. This strongly suggests a client-side issue in the Bun runtime
embedded in the Claude Code binary (or its interaction with this user's
network/TLS path), not generic network reachability.
Headline numbers (last ~30 days):
| Metric | Value |
| --- | --- |
| Total
ECONNRESETevents logged across sessions | 887 || Distinct sessions impacted | 41 |
| Distribution across retries 1–10 | Steady decay (138, 135, 111, 93, 78, 67, 57, 50, 46, 45) — many requests exhaust the full retry budget |
| Sessions ended without ever getting a response | Multiple (per
/insightssummary, ~5 of 39 analyzed) || Curl direct test against
api.anthropic.com| 5/5 successful, ~20 ms total |---
2. Environment
2.1 Host / OS
| Field | Value |
| --- | --- |
| Hardware | Apple Silicon (
arm64) MacBook || OS | macOS 26.4.1 (build 25E253) |
| Kernel | Darwin 25.4.0 (
xnu-12377.101.15~1/RELEASE_ARM64_T8140) || Shell |
/bin/zsh|| Hostname |
Jasons-MacBook.local|2.2 Claude Code
| Field | Value |
| --- | --- |
| Version | 2.1.126 |
| Install method | Homebrew Cask (
/opt/homebrew/Caskroom/claude-code/2.1.126/) || Binary type |
Mach-O 64-bit executable arm64(single-file Bun-bundled binary, 216 MB) || Runtime hint (from stack traces) | Bun (
/$bunfs/root/src/entrypoints/cli.js,native:7:39) || Entrypoint |
cli(CLAUDE_CODE_ENTRYPOINT=cli,AI_AGENT=claude-code/2.1.126/agent) || Auto-update channel |
stable||
numStartups| 138 || MCP servers configured | none (
mcpServers: {}) || Hooks configured | 0 hooks loaded |
| Plugins | 0 enabled |
| Custom skills/agents | none in
~/.claude/{skills,agents,commands}(all ENOENT) || Telemetry |
CLAUDE_CODE_ENABLE_TELEMETRYunset (3P telemetry disabled), but 1P event logging is still attempting export and also hitting ECONNRESET |~/.claude/settings.json:2.3 Network
| Field | Value |
| --- | --- |
| ISP / upstream | CenturyLink/Lumen (DSL via
hlrn.qwest.net) || Local LAN |
en0,192.168.0.76/24, MTU 1500 || DNS resolvers |
192.168.0.1(modem),205.171.2.65(Qwest/Lumen) ||
api.anthropic.comresolves to |160.79.104.10|| Path to API | LAN → modem → Qwest → Lumen Denver edge → Cloudflare (
172.68.32.x) → Anthropic (160.79.104.10); 8 hops, ~5 ms || Application Firewall | Disabled (
State = 0) || HTTP(S) proxy env vars | None set |
|
ANTHROPIC_CUSTOM_HEADERS| Not present |2.4 VPN / virtual interfaces (potentially relevant)
There are six active
utuntunnels with assorted MTUs (1000, 1280, 1380,1500, 2000).
scutil --nwireportsen0is the only IPv4 routable interfaceand IPv6 is "No IPv6 states found", so traffic should egress on
en0(MTU1500). However the
mtu 1000andmtu 1380tunnels are typical of corporateVPN clients (Cisco AnyConnect / Cloudflare WARP / Tailscale / GlobalProtect),
and
curl --http2succeeds while Bun's HTTP/2 client does not — worthinvestigating an interaction.
---
3. Reproducibility evidence
3.1 Direct connectivity to
api.anthropic.comis healthytracerouteis clean across all 8 hops, no* * *past hop 4.3.2 Failures inside Claude Code
Source:
~/.claude/debug/latest(current session, 2026-05-09):Note: the model request did receive its first chunk before being interrupted
— failures are happening mid-stream, not at connect time. Sub-requests
(
source=generate_session_title) and 1P/3P event exporters fail in the sameinterval.
A typical exhausted-retry burst (eleven attempts back-to-back, none succeed,
final
x-client-request-idleft for server-log lookup):3.3 Canonical error object (from session JSONL)
The exponential-backoff jitter ladder observed:
~512ms → ~1040ms → ~2020ms →(consistent with~4530ms → …
2^n+ jitter), running to attempt 10/10.3.4 Telemetry / 1P event logger errors (same root cause, different endpoint)
The phrase
pass verbose: true in the second argument to fetch()is Bun'sfetch error format. This confirms the failures are originating in the Bun
runtime's HTTP client.
---
4. Important
x-client-request-ids for server-side correlationThese are exhausted-retry final IDs the CLI itself flagged as
"give this to the API team for server-log lookup":
a8a4b32a-6ed4-42b0-98f0-875a1296456d— 2026-05-09T20:32:48Z6027a507-9112-425e-a26f-27c5fa0292e9— 2026-05-09T20:32:54Zf7115f2a-5a9f-4d0f-a7e0-7aa5fb665546— 2026-05-09T20:34:57Z (source=repl_main_thread)b4778bf6-1518-44cb-a7e4-ac6fafed00ee— 2026-05-09T20:35:02Z (source=generate_session_title)e9b03d4e-25d9-4016-b601-55191716c469— 2026-05-09T20:30:00Z (source=generate_session_title)25c442f3-3d3b-4920-9ec8-f59a31e6ce98— 2026-05-09T20:30:27Z (source=generate_session_title)Many additional IDs are available in
~/.claude/debug/7cf0798e-0996-4915-b21c-f3b501fa6d3f.txtand the per-sessionJSONLs under
~/.claude/projects/.---
5. Temporal pattern
ECONNRESETevents are not uniformly distributed; they cluster around activesessions. Top hours (UTC):
This rules out a single short Anthropic-side outage and suggests a
chronic condition triggered by the user's environment + client behaviour,
not a one-off backend incident. Once a session enters the failing state it
tends to fail across many minutes.
---
6. Hypotheses ranked by evidence
6.1 (Most likely) Bun fetch / HTTP-2 client + middlebox interaction
native:7:39,/$bunfs/root/src/entrypoints/cli.js).curlto the same host, including--http2, is bulletproof from thismachine.
Stream started - received first chunk, i.e. duringlong-lived streaming response bodies — exactly the surface area where Bun's
HTTP/2 stream handling has historically had reset bugs.
utuntunnels with non-1500 MTUs are present; if Bun's HTTP/2implementation differs from libcurl's in how it handles PMTU / window
updates / keepalive over a connection that briefly egresses through one of
these tunnels, that would manifest exactly like this.
Suggested investigation: which exact Bun version is bundled in 2.1.126?
Are there known issues in Bun's HTTP/2 client around streaming RST_STREAM /
GOAWAY handling that match this signature? Can the CLI fall back to HTTP/1.1
for
/v1/messagesas a workaround?6.2 Cloudflare edge in front of
api.anthropic.comresetting long-idle / mid-stream connectionsHops 7 (
172.68.32.12 / 172.68.32.28) are Cloudflare. Cloudflare edges havebeen observed to send
RSTto clients that violate their HTTP/2 keepaliveping cadence or frame-size expectations. Worth checking server-side whether
these
x-client-request-ids show acf-reset reason or upstream cancel.6.3 Bundled-binary CA / mTLS path interaction
Debug log shows:
system store returned emptyon macOS 26.4.1 is suspicious — usually macOS'skeychain contributes additional roots. If the bundled mTLS agent is
re-handshaking unnecessarily or rotating sockets, that could explain the
mid-stream resets. Probably a secondary factor at most, but worth confirming.
6.4 (Lower likelihood) ISP / DSL pacing
CenturyLink/Lumen DSL with a consumer modem (
192.168.0.1) can RST long-livedTCP flows under load. But:
curllong polls don't see this, and the resetsare reproducible during very short request windows, so the ISP angle is
unlikely to be primary.
---
7. What I (the user) have already verified
ping,traceroute,curl, andcurl --http2toapi.anthropic.comallsucceed reliably and quickly.
extraCertsPath.~/.claude/projects/shows 41 distinct session IDs hitting it across
git/kina,git/beads,tmp/urface,git/taljazzco/...,tmp/econnreset, etc.).2.1.119and2.1.126, so not a single-buildregression that has since been fixed.
---
8. What would help Anthropic root-cause this
x-client-request-ids in §4 — was thestream cancelled by the API, by Cloudflare, or by the client? What does the
cf-ray/ disconnect-reason header show?known Bun fetch-streaming reset issues? Is a fall-back to HTTP/1.1 viable?
CLAUDE_CODE_FORCE_HTTP1(or equivalent) env-var workaround so userson networks where Bun-h2 misbehaves can keep working while a fix lands.
--verbose-fetchflag that turns on Bun fetch'sverbose: true(theerror message itself recommends this) — currently there is no user-facing
way to enable it.
CLAUDE_CODE_DISABLE_TELEMETRY_EXPORT=1that fully suppresses 1Pevent-logging POSTs as well, since those exporters are also failing and
adding noise to the logs.
---
9. Artefact bundle (paths on this machine)
If the API team needs the raw evidence:
~/.claude/debug/latest→ symlink to current debug log(
7cf0798e-0996-4915-b21c-f3b501fa6d3f.txt, ~107 KB).~/.claude/debug/*.txt→ 8 prior debug logs from 2026-05-06 → 2026-05-09.~/.claude/projects/*/[uuid].jsonl→ per-session conversation logs;every line with
"subtype":"api_error"is an ECONNRESET event with fullmetadata (timestamp, sessionId, retryAttempt, retryInMs, version, cwd,
gitBranch).
``
``grep -rh ECONNRESET ~/.claude/projects \
| grep -oE '"sessionId":"[^"]+"' | sort -u
~/.claude.json→ CLI state file (cached GrowthBook flags, startup history).I am happy to share any of these directly with Anthropic Support on request.
---
10. Impact on me as a user
Per the
/insightssummary the CLI itself produced on 2026-05-07:That matches my lived experience: 887 ECONNRESETs across 41 sessions in ~30
days, with several sessions producing zero successful responses despite
exhausting the full 10–11-attempt retry ladder. This makes Claude Code
effectively unusable for sustained work in my environment, which is
particularly frustrating given that every other HTTPS client on the same
machine talks to
api.anthropic.comwithout issue.Root cause found — links to the IPv6 and Docker observations in this thread
Posting findings from a deep investigation on Linux (#60133) that explains several comments in this thread.
Root cause: Bun does not set
SO_KEEPALIVEThe claude binary bundles Bun 1.3.14 as its runtime. Bun's
fetch()does not setSO_KEEPALIVEon TCP sockets. Without it, idle connections (during tool execution gaps in agentic sessions) are silently dropped. Confirmed live:Why "disabling IPv6 fixed it" (@myongwha)
api.anthropic.comresolves to IPv6 first viagetaddrinfo. Bun uses the first result, so it connects over IPv6 by default. IPv6 routing through home routers tends to have shorter stateful firewall timeouts than IPv4 NAT, making idle connections more likely to be dropped. Forcing IPv4 viaNODE_OPTIONS="--dns-result-order=ipv4first"has the same effect as disabling IPv6 system-wide, without the side effects.Why "setting Docker MTU to 1492 fixed it" (@posborneao)
Docker bridges lower the effective path MTU, which can cause TCP segment fragmentation on IPv6 paths. With fragmented packets, TCP keepalive probes (from other apps) may not reach the server cleanly — but since claude sends no keepalive probes at all, the MTU change incidentally affects routing path selection in a way that changes which connections get dropped first.
Workaround
For a complete OS-level fix that forces
SO_KEEPALIVEon all claude sockets:Full investigation with binary analysis,
ssoutput comparisons, and feature flag dump: #60133the workaround envvars do not seem to offer any improvement for me
Its because it's an Anthropic's API issue. And idk, but I suspect it's intentional for PRO users' accounts only.
it's so genuinely unusable that I've given up and canceled my pro subscription
@jpackagejasonc definitely, same from here. This one was from today's interaction.
<img width="1368" height="446" alt="Image" src="https://github.com/user-attachments/assets/e97d6339-97fa-4e3d-ad8b-4cf6506eea37" />
I hope more people start posting about this issue here so that Anthropic begins working on a solution for these annoying errors. I’m genuinely considering canceling my subscription.
Claude CLI is basically unusable for me right now until this gets fixed. What’s interesting is that the issue only seems to happen on my machine/account as my coworkers are able to use the API normally. I hope they get rid of the error soon... What Im doing to avoid the error is starting new sessions everytime I finish a task, it seems like a temporary fix, but even though it crashes 2 to 3 times per session while doing this.
Root cause found for persistent ECONNRESET: MTU blackhole (path drops full-size frames, PMTUD broken)
TL;DR: Months of
Unable to connect to API (ECONNRESET)on every request turned out to be a network-path MTU problem, not Claude Code, not my account, and not anything in~/.claude. The path between my machine and the internet silently drops full-size (1500-byte) packets and never sends the ICMP "fragmentation needed" signal back, so PMTU discovery is blacked out. Small requests succeed; any request with a large body — i.e., every real Claude Code request — gets reset within one RTT. Clamping interface MTU to 1400 fixed it instantly.If you're in this thread with "all diagnostics pass but Claude Code can't connect," try the 5-minute test below before anything else.
Environment
Retrying in Xs · attempt Y/10→ ~3 minutes →Unable to connect to API (ECONNRESET)rm -rf ~/.claude, clean reinstalls,/logout//login, and two different accounts (CLAUDE_CONFIG_DIRisolated). A second machine on the same LAN worked fine, which made it look like an account/edge problem. It wasn't.Why every standard diagnostic passed
All the usual checks use small packets, so they can't see this failure:
curl -I https://api.anthropic.com→ finecurlGET/v1/modelsover both IPv4 and IPv6 → HTTP 401 (transport fine)systemextensionsctl list→ 0 extensions;pfctl -sr→ stock Apple rulesMeanwhile in
claude --debuglogs:/v1/messages(the CLI's API-key verification probe) succeeded — real HTTP 400 from the API with arequest_id, ~170 ms/v1/messagesrequest (system prompt + context = hundreds of KB) went from[API REQUEST]toAPI error (attempt N/11): undefined Connection error.in 25–40 ms — an active reset on the first large write, not a timeoutPattern: payload-size-dependent connection kill.
The 5-minute test (no Claude software involved)
My result:
If the large POST resets where the small one passes, confirm with a ping ladder (don't-fragment full-size frames):
My result: 66% loss at 1472, 0% loss at 1372 and below. Clean size cliff = MTU blackhole (likely tunnel/PPPoE-style encapsulation upstream eating header bytes, with ICMP frag-needed filtered somewhere).
The fix
Large curl POST immediately returned
401, and Claude Code connected on the next run. Permanent fix is at the router: set WAN MTU appropriately / enable MSS clamping so every device is covered. (Revert the Mac withnetworksetup -setMTU Wi-Fi 1500once the router is fixed.) Worth a ticket to your ISP too — dropping 1500-byte frames while blackholing PMTUD is broken on their side.Why one machine on the same LAN worked and another didn't: different link/negotiation between the two devices — "same network" does not mean same effective path MTU behavior, and only a tool that sends sustained large upstream payloads (like an LLM CLI shipping full context on every request) reliably trips it.
Suggestion for the Claude Code team
API error (attempt N/11): undefined Connection error.carries zero diagnostic signal for this entire failure class. Two cheap improvements would have saved me three months:undefined Connection error.Hope this unblocks someone else in this thread.