claude-code - 💡(How to fix) Fix [Bug] Socket connection closed unexpectedly during Anthropic API request

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…

Error Message

[{"error":"Error: 1: Command failed with ERR_STREAM_PREMATURE_CLOSE: code --force --install-extension anthropic.claude-code\nPremature close \n at Qf1 (/$bunfs/root/src/entrypoints/cli.js:1573:4045)\n at async df1 (/$bunfs/root/src/entrypoints/cli.js:1573:1435)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-04-20T11:48:21.534Z"},{"error":"The socket connection was closed unexpectedly. For more information, pass verbose: true in the second argument to fetch()","timestamp":"2026-04-20T11:57:25.023Z"}]

Code Example

[{"error":"Error: 1: Command failed with ERR_STREAM_PREMATURE_CLOSE: code --force --install-extension anthropic.claude-code\nPremature close \n    at Qf1 (/$bunfs/root/src/entrypoints/cli.js:1573:4045)\n    at async df1 (/$bunfs/root/src/entrypoints/cli.js:1573:1435)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-20T11:48:21.534Z"},{"error":"The socket connection was closed unexpectedly. For more information, pass `verbose: true` in the second argument to fetch()","timestamp":"2026-04-20T11:57:25.023Z"}]
RAW_BUFFERClick to expand / collapse

Bug Description API Error: The socket connection was closed unexpectedly. For more information, pass verbose: true in the second argument to fetch()

Environment Info

  • Platform: darwin
  • Terminal: vscode
  • Version: 2.1.113
  • Feedback ID: 3197ac90-24a4-4dce-b6e9-fa19eac0473d

Errors

[{"error":"Error: 1: Command failed with ERR_STREAM_PREMATURE_CLOSE: code --force --install-extension anthropic.claude-code\nPremature close \n    at Qf1 (/$bunfs/root/src/entrypoints/cli.js:1573:4045)\n    at async df1 (/$bunfs/root/src/entrypoints/cli.js:1573:1435)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-20T11:48:21.534Z"},{"error":"The socket connection was closed unexpectedly. For more information, pass `verbose: true` in the second argument to fetch()","timestamp":"2026-04-20T11:57:25.023Z"}]

extent analysis

TL;DR

Pass verbose: true in the second argument to fetch() to gather more information about the unexpected socket connection closure.

Guidance

  • The error message suggests a premature closure of the socket connection, which may be related to the fetch() call.
  • To troubleshoot, pass verbose: true in the second argument to fetch() as recommended in the error message.
  • Verify that the fetch() call is properly configured and that the server is responding correctly.
  • Check the network connection and any proxy settings that may be interfering with the request.

Example

No code snippet is provided as the issue does not contain sufficient information about the fetch() call.

Notes

The provided information is limited, and the root cause of the issue is unclear. Gathering more information with verbose: true may help identify the problem.

Recommendation

Apply workaround: Pass verbose: true in the second argument to fetch() to gather more information about the issue, as this may help identify the root cause of the problem.

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] Socket connection closed unexpectedly during Anthropic API request