claude-code - 💡(How to fix) Fix [BUG] ECONNRESET on every API call — macOS 26 Tahoe, Darwin 25.4.0, ARM64 [1 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#56059Fetched 2026-05-05 05:59:16
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Participants
Timeline (top)
labeled ×5cross-referenced ×1

Error Message

From session with version 2.1.121: 2026-05-04T14:27:23.549Z [ERROR] API error (attempt 11/11): undefined Connection error. 2026-05-04T14:27:23.557Z [ERROR] Error in API request: Connection error. 2026-05-04T14:27:23.559Z [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() 2026-05-04T14:27:23.560Z [ERROR] API error x-client-request-id=adcb0f2c-2946-4357-b8e3-a4e42651e1cb (give this to the API team for server-log lookup)

From session with version 2.1.126 (after clean reinstall): 2026-05-04T15:57:16.688Z [DEBUG] [API REQUEST] /v1/messages x-client-request-id=99a76400-6c9d-43dd-90a0-52b5bf2aa0c3 source=repl_main_thread 2026-05-04T15:57:16.738Z [ERROR] API error (attempt 11/11): undefined Connection error. 2026-05-04T15:57:16.740Z [ERROR] Error in API request: Connection error. 2026-05-04T15:57:16.741Z [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() 2026-05-04T15:57:16.742Z [ERROR] API error x-client-request-id=99a76400-6c9d-43dd-90a0-52b5bf2aa0c3 (give this to the API team for server-log lookup) 2026-05-04T15:57:16.743Z [ERROR] Error: Error: Connection error. at makeRequest (/$bunfs/root/src/entrypoints/cli.js:50:4056) at processTicksAndRejections (native:7:39)

Code Example

From session with version 2.1.121:
2026-05-04T14:27:23.549Z [ERROR] API error (attempt 11/11): undefined Connection error.
2026-05-04T14:27:23.557Z [ERROR] Error in API request: Connection error.
2026-05-04T14:27:23.559Z [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()
2026-05-04T14:27:23.560Z [ERROR] API error x-client-request-id=adcb0f2c-2946-4357-b8e3-a4e42651e1cb (give this to the API team for server-log lookup)

From session with version 2.1.126 (after clean reinstall):
2026-05-04T15:57:16.688Z [DEBUG] [API REQUEST] /v1/messages x-client-request-id=99a76400-6c9d-43dd-90a0-52b5bf2aa0c3 source=repl_main_thread
2026-05-04T15:57:16.738Z [ERROR] API error (attempt 11/11): undefined Connection error.
2026-05-04T15:57:16.740Z [ERROR] Error in API request: Connection error.
2026-05-04T15:57:16.741Z [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()
2026-05-04T15:57:16.742Z [ERROR] API error x-client-request-id=99a76400-6c9d-43dd-90a0-52b5bf2aa0c3 (give this to the API team for server-log lookup)
2026-05-04T15:57:16.743Z [ERROR] Error: Error: Connection error.
    at makeRequest (/$bunfs/root/src/entrypoints/cli.js:50:4056)
    at processTicksAndRejections (native:7:39)
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?

Environment OS: Darwin 25.4.0, RELEASE_ARM64_T6000, arm64 (macOS 26 Tahoe) Claude Code versions tested: 2.1.121, 2.1.122, 2.1.123, 2.1.126 (all affected) Machine: Apple ARM64 T6000 What is wrong Every API call to api.anthropic.com/v1/messages fails with ECONNRESET after ~50ms. Claude Code retries 11 times then gives up. The session is completely non-functional.

What Should Happen?

Claude Code should connect to the API normally.

Error message API error (attempt N/11): undefined Connection error. Connection error details: code=ECONNRESET, The socket connection was closed unexpectedly.

Diagnosis Claude Code uses Bun's Network.framework for HTTP on ARM macOS. Node.js reaches api.anthropic.com cleanly but Bun does not. Running the following Node.js test returns STATUS 401 as expected, confirming the network path is healthy. Claude Code fails with ECONNRESET on every attempt using the same network. Additionally, MCP proxy connections to mcp-proxy.anthropic.com via Bun do complete successfully (received Cloudflare 502), so the issue appears specific to api.anthropic.com rather than a blanket Bun networking failure.

What was ruled out

  • Corporate firewall or proxy: curl and openssl s_client both connect and complete TLS handshake successfully.
  • Auth and OAuth: token checks succeed every time.
  • TLS certificates: only one system CA cert present (Apple com.apple.systemdefault), no corporate CA interference.
  • Corrupted installation: full clean uninstall and reinstall to 2.1.126 shows identical failure.
  • Attempted fixes with no effect
  • CLAUDE_CODE_DISABLE_MTLS=1
  • Full clean uninstall including npm package, binary, ~/.claude/, ~/.claude.json, ~/.local/share/claude/, and Keychain credentials.
  • Reinstall to latest version 2.1.126.

Error Messages/Logs

From session with version 2.1.121:
2026-05-04T14:27:23.549Z [ERROR] API error (attempt 11/11): undefined Connection error.
2026-05-04T14:27:23.557Z [ERROR] Error in API request: Connection error.
2026-05-04T14:27:23.559Z [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()
2026-05-04T14:27:23.560Z [ERROR] API error x-client-request-id=adcb0f2c-2946-4357-b8e3-a4e42651e1cb (give this to the API team for server-log lookup)

From session with version 2.1.126 (after clean reinstall):
2026-05-04T15:57:16.688Z [DEBUG] [API REQUEST] /v1/messages x-client-request-id=99a76400-6c9d-43dd-90a0-52b5bf2aa0c3 source=repl_main_thread
2026-05-04T15:57:16.738Z [ERROR] API error (attempt 11/11): undefined Connection error.
2026-05-04T15:57:16.740Z [ERROR] Error in API request: Connection error.
2026-05-04T15:57:16.741Z [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()
2026-05-04T15:57:16.742Z [ERROR] API error x-client-request-id=99a76400-6c9d-43dd-90a0-52b5bf2aa0c3 (give this to the API team for server-log lookup)
2026-05-04T15:57:16.743Z [ERROR] Error: Error: Connection error.
    at makeRequest (/$bunfs/root/src/entrypoints/cli.js:50:4056)
    at processTicksAndRejections (native:7:39)

Steps to Reproduce

  1. Install Claude Code on a Mac running macOS 26 Tahoe (Darwin 25.4.0) on ARM64 hardware
  2. Run claude and attempt any prompt
  3. Observe ECONNRESET errors on every API call, retrying up to 11 times before giving up
  4. Confirm network is healthy by running: curl -v https://api.anthropic.com/v1/models -H "x-api-key: dummy" (returns 401 as expected)
  5. Confirm Node.js reaches the API: node -e "const https = require('https'); https.get('https://api.anthropic.com/v1/models', {headers: {'x-api-key': 'dummy'}}, r => console.log('STATUS:', r.statusCode)).on('error', e => console.error('ERROR:', e.code, e.message));" (returns STATUS 401 as expected)
  6. Claude Code continues to fail while both curl and Node.js succeed from the same machine

Claude Model

Not sure / Multiple models

Is this a regression?

I don't know

Last Working Version

Was working on 2.1.121 but with a previous macOS version

Claude Code Version

2.1.126

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

extent analysis

TL;DR

The issue is likely related to Bun's Network.framework on ARM macOS, causing ECONNRESET errors when connecting to the Anthropic API, and a workaround or fix may involve configuring or updating the networking settings.

Guidance

  • Investigate the differences in networking behavior between Bun and Node.js on ARM macOS to identify the root cause of the ECONNRESET errors.
  • Verify that the issue is specific to the Anthropic API by testing connections to other APIs using Bun.
  • Consider updating or reconfiguring the Network.framework or Bun's networking settings to resolve the issue.
  • Test the CLAUDE_CODE_DISABLE_MTLS=1 environment variable again, as it may have been overlooked or not properly applied.

Example

No code example is provided, as the issue is related to the underlying networking framework and not a specific code snippet.

Notes

The issue may be specific to the combination of ARM macOS, Bun, and the Anthropic API, and further investigation is needed to determine the root cause.

Recommendation

Apply a workaround by investigating alternative networking configurations or updating the Network.framework, as the issue is likely related to the underlying networking settings.

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