claude-code - 💡(How to fix) Fix Native update/install fails with 'socket connection was closed unexpectedly' behind proxy — undici TLS incompatibility

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…

claude update and claude install consistently fail with:

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

This occurs when running behind a proxy (system proxy enabled). The issue is specific to the bundled undici fetch() inside claude.exe — all other methods of accessing the same URL work fine.

Error Message

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

Root Cause

The TLS handshake fails specifically inside the bundled undici in claude.exe. This was confirmed by:

# System Node.js fetch works fine
node -e "fetch('https://downloads.claude.ai/claude-code-releases/latest').then(r => r.text()).then(console.log)"
# Output: 2.1.153 ✅

# But claude.exe fails on the same URL
claude update
# Error: socket connection was closed unexpectedly ❌

Setting NODE_TLS_REJECT_UNAUTHORIZED=0 does not resolve the issue for claude.exe, suggesting the problem is deeper than certificate validation — likely an incompatibility between the bundled undici version's TLS implementation and certain proxy configurations.

Code Example

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

---

# System Node.js fetch works fine
node -e "fetch('https://downloads.claude.ai/claude-code-releases/latest').then(r => r.text()).then(console.log)"
# Output: 2.1.153
# But claude.exe fails on the same URL
claude update
# Error: socket connection was closed unexpectedly ❌
RAW_BUFFERClick to expand / collapse

Description

claude update and claude install consistently fail with:

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

This occurs when running behind a proxy (system proxy enabled). The issue is specific to the bundled undici fetch() inside claude.exe — all other methods of accessing the same URL work fine.

Environment

  • OS: Windows 11
  • Claude Code version: 2.1.153 (native install)
  • System Node.js: v24.15.0
  • Proxy: HTTP/HTTPS proxy on localhost

Reproduction

  1. Run behind a proxy
  2. Execute claude update or claude install
  3. Fails immediately with the socket error

What works vs. what doesn't

MethodResult
Browser access to downloads.claude.ai✅ Works
curl https://downloads.claude.ai/claude-code-releases/latest✅ Works
Node.js https.get() (system Node v24)✅ Works
Node.js fetch() (system Node v24)✅ Works
claude.exe internal fetch() (bundled Node)❌ Fails

Root cause analysis

The TLS handshake fails specifically inside the bundled undici in claude.exe. This was confirmed by:

# System Node.js fetch works fine
node -e "fetch('https://downloads.claude.ai/claude-code-releases/latest').then(r => r.text()).then(console.log)"
# Output: 2.1.153 ✅

# But claude.exe fails on the same URL
claude update
# Error: socket connection was closed unexpectedly ❌

Setting NODE_TLS_REJECT_UNAUTHORIZED=0 does not resolve the issue for claude.exe, suggesting the problem is deeper than certificate validation — likely an incompatibility between the bundled undici version's TLS implementation and certain proxy configurations.

Additional context

  • The same claude.exe version (2.1.153) works on one machine but fails on another with the same system Node.js version (v24.15.0), suggesting the bundled Node.js/undici version may differ or there's a subtle environmental difference in how the binary interacts with the proxy.
  • Related issues: #60133 (SO_KEEPALIVE analysis), #37801 (update fails but curl works), #13498 (GCS timeout)

Suggestion

Consider adding proxy support to the native updater (respecting HTTP_PROXY/HTTPS_PROXY environment variables) or falling back to https.get when fetch() fails.

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