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
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.
- From the same shell, use your approved proxy test to reach `https://api.anthropic.com/api/hello`.
- Test `https://platform.claude.com/v1/oauth/hello` through the same proxy.
- Keep proxy credentials redacted from screenshots and logs.
- 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`.
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.
- Record the working proxy configuration and current Claude Code version.
- Upgrade using the same official installation channel already in use.
- Start a new shell so proxy variables are inherited cleanly.
- 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.
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.
- Get approval for the temporary older version and record the rollback target.
- Install Claude Code 2.1.190 through the same npm channel.
- Verify the installed version before entering credentials.
- Start interactively and test a harmless prompt through the proxy.
npm install -g @anthropic-ai/claude-code@2.1.190Expected: Claude Code proceeds past startup and real API traffic uses the already-verified proxy.
Verification
Prove the fix worked
- Interactive startup reaches login or the prompt without `ERR_SOCKET_CLOSED`.
- A harmless real API request succeeds through the corporate proxy.
- 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.
First-hand preflight isolation, exact error, and confirmed 2.1.190 workaround.
Official proxy variables, authentication, CA trust, and network requirements.
Official connection-error decision points and warning not to disable TLS verification.