AgentFixFind a fix
Claude CodePartial workaroundUpdated Aug 20, 2026

Claude Code startup fails with ERR_SOCKET_CLOSED behind a proxy

Fix the Claude Code 2.1.220 startup preflight regression that returns ERR_SOCKET_CLOSED behind a working corporate HTTPS proxy.

Exact error

Match the message before using the fix

Failed to connect to api.anthropic.com: ERR_SOCKET_CLOSEDUnable to connect to Anthropic servicesChecking connectivity...

Quick answer

Start here

Confirm the proxy is actually working before using this page: the two Anthropic preflight URLs must succeed through the same proxy while interactive Claude Code 2.1.220 alone returns `ERR_SOCKET_CLOSED`. Upgrade to the current supported release first. If the exact regression persists and your organization permits a temporary version pin, the reporter confirmed that 2.1.190 starts successfully. No documented skip-connectivity environment variable existed in the checked sources.

Diagnosis

Why it happens

  • In the source report, the interactive startup preflight used a different HTTP path from normal SDK requests and failed through a TLS-to-proxy connection.
  • The proxy itself was reachable: curl and the SDK path reached the same Anthropic endpoints through it.
  • The upstream issue is closed, but no fixed release is documented on the issue; closure alone does not prove the behavior is repaired in every later version.

Safest first

Fixes, in order

01

Confirm the proxy works outside the startup preflight

Applies when: Only when Claude Code stalls at `Checking connectivity` and then reports `ERR_SOCKET_CLOSED`

A failing proxy, CA trust problem, firewall, or unsupported country is a different branch.

  1. From the same shell, use your approved proxy test to reach `https://api.anthropic.com/api/hello`.
  2. Test `https://platform.claude.com/v1/oauth/hello` through the same proxy.
  3. Keep proxy credentials redacted from screenshots and logs.
  4. Confirm the startup preflight fails while those proxy-aware requests succeed.

Expected: Both endpoints are reachable through the proxy, but interactive 2.1.220 alone fails with `ERR_SOCKET_CLOSED`.

02

Upgrade before pinning an old release

Applies when: Installations still on the affected 2.1.220 build

Claude Code 2.1.237 was current in the npm registry when checked, but the issue does not identify the exact fixed version.

  1. Record the working proxy configuration and current Claude Code version.
  2. Upgrade using the same official installation channel already in use.
  3. Start a new shell so proxy variables are inherited cleanly.
  4. Retry interactive startup and the first harmless prompt.

Expected: The current release either starts normally or proves the exact regression still affects your proxy setup.

03

Temporarily pin the reporter-confirmed version

Applies when: When the exact regression persists, the installation is npm-managed, and organizational policy allows a temporary downgrade

The reporter confirmed 2.1.190 does not run the blocking preflight and can use the working proxy for real API traffic.

  1. Get approval for the temporary older version and record the rollback target.
  2. Install Claude Code 2.1.190 through the same npm channel.
  3. Verify the installed version before entering credentials.
  4. Start interactively and test a harmless prompt through the proxy.
npm install -g @anthropic-ai/claude-code@2.1.190

Expected: Claude Code proceeds past startup and real API traffic uses the already-verified proxy.

Verification

Prove the fix worked

  1. Interactive startup reaches login or the prompt without `ERR_SOCKET_CLOSED`.
  2. A harmless real API request succeeds through the corporate proxy.
  3. Record the working Claude Code version and return to a current release once the regression is confirmed resolved.

Escalation

If it still fails

  • If curl through the proxy also fails, follow the official proxy, CA, and network requirements instead of downgrading.
  • Do not invent or set `CLAUDE_CODE_SKIP_CONNECTIVITY_CHECK`; it was only a suggested upstream fix, not a documented variable.
  • Do not set `NODE_TLS_REJECT_UNAUTHORIZED=0`, which disables certificate verification.

Scope

Environment and version notes

  • The confirmed regression and downgrade report used Claude Code 2.1.220 and 2.1.190 on Linux/macOS tooling; Windows applicability was not established.
  • Claude Code 2.1.237 was current in the npm registry on August 20, 2026, but the closed issue does not name a fixed release.
  • Sources rechecked August 20, 2026.

Evidence

Sources

Source labels describe the evidence available on the checked date. A closed issue is not automatically a shipped fix.