claude-code - 💡(How to fix) Fix [BUG] ECONNRESET on streaming connections - Claude Code 2.1.107 (macOS arm64) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#48008Fetched 2026-04-15 06:35:58
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Author
Timeline (top)
labeled ×5commented ×1cross-referenced ×1

Error Message

Claude Code drops streaming connections with ECONNRESET errors 60+ times per day during active coding sessions. The error occurs both during file writing and short conversations. The connection to api.anthropic.com is healthy — curl returns expected responses with no packet loss. Error from Claude Code logs: API error (attempt 11/11): undefined Connection error. Error in API request: Connection error. Connection error details: code=ECONNRESET, message=The socket connection was closed unexpectedly. [3P telemetry] OTEL diag error: Failed to export 3 events (code=ECONNRESET) Error persists across VS Code restarts and user logout/login cycles The Cloudflare edge node in Santiago, Chile (SCL) appears to be closing idle streaming connections before Claude Code completes its response. The error consistently occurs during pauses in streaming while the model is processing or writing long files. Short curl requests to the same endpoint succeed without issue.

Error Messages/Logs

RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Claude Code drops streaming connections with ECONNRESET errors 60+ times per day during active coding sessions. The error occurs both during file writing and short conversations. The connection to api.anthropic.com is healthy — curl returns expected responses with no packet loss. Error from Claude Code logs: API error (attempt 11/11): undefined Connection error. Error in API request: Connection error. Connection error details: code=ECONNRESET, message=The socket connection was closed unexpectedly. x-client-request-id=3ff35c82-b5ff-475b-ba2b-835759f12c4b 1P event logging: 3 events failed to export (code=ECONNRESET) [3P telemetry] OTEL diag error: Failed to export 3 events (code=ECONNRESET) Troubleshooting already performed:

Confirmed api.anthropic.com is reachable — curl returns HTTP 401 (expected) with no errors Traceroute shows 6 hops, ~8ms latency, zero packet loss Uninstalled GitHub Copilot and all other AI extensions Verified Anthropic status page shows green Verified the issue is NOT related to available RAM (2.3GB free during errors) Applied macOS TCP keepalive tuning (net.inet.tcp.keepidle, net.inet.tcp.keepintvl, net.inet.tcp.keepcnt) — reduced frequency but did not eliminate the issue Error persists across VS Code restarts and user logout/login cycles

What Should Happen?

Hypothesis: The Cloudflare edge node in Santiago, Chile (SCL) appears to be closing idle streaming connections before Claude Code completes its response. The error consistently occurs during pauses in streaming while the model is processing or writing long files. Short curl requests to the same endpoint succeed without issue. Request: Please investigate whether the streaming connection timeout configuration on the Cloudflare edge layer for the SCL region is compatible with Claude Code's streaming behavior, and whether the client should implement more aggressive keepalive or reconnection logic for long-running responses.

Error Messages/Logs

Steps to Reproduce

just send a instruction to Claude Code and you will get ERRRCONNECT

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.107

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

VS Code integrated terminal

Additional Information

No response

extent analysis

TL;DR

Investigate and adjust the streaming connection timeout configuration on the Cloudflare edge layer for the SCL region to prevent premature closure of idle connections.

Guidance

  • Verify the current streaming connection timeout settings on the Cloudflare edge layer for the SCL region to determine if they are compatible with Claude Code's streaming behavior.
  • Consider implementing more aggressive keepalive or reconnection logic in the Claude Code client to maintain long-running connections.
  • Review the API documentation for any recommendations on handling connection timeouts and idle connections.
  • Test the connection timeout settings with a tool like curl or a custom script to simulate Claude Code's streaming behavior.

Notes

The issue seems to be related to the Cloudflare edge node closing idle streaming connections prematurely, but without direct access to the Cloudflare configuration or the Claude Code implementation, it's difficult to provide a definitive solution.

Recommendation

Apply workaround: Implement more aggressive keepalive or reconnection logic in the Claude Code client to maintain long-running connections, as adjusting the Cloudflare edge layer settings may not be feasible or immediate.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] ECONNRESET on streaming connections - Claude Code 2.1.107 (macOS arm64) [1 comments, 2 participants]