[BUG] ECONNRESET on streaming connections - Claude Code 2.1.107 (macOS arm64)
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?
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_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗