[BUG] Claude Code 2.1.152 returns ConnectionRefused with Anthropic-compatible endpoint while PowerShell and Node HTTPS succeed

Resolved 💬 1 comment Opened May 27, 2026 by budaniao88 Closed Jun 28, 2026

Bug Report Draft: Claude Code ConnectionRefused with Anthropic-compatible endpoint on Windows

Title

Claude Code 2.1.152 returns ConnectionRefused when using Anthropic-compatible BigModel endpoint, while PowerShell and Node HTTPS succeed

Summary

Claude Code fails to call an Anthropic-compatible endpoint on Windows with:

API Error: Unable to connect to API (ConnectionRefused)

The same machine can reach the endpoint successfully with curl, PowerShell/.NET, and plain Node.js HTTPS. A local Node HTTP proxy that forwards to the same upstream endpoint works around the issue, which suggests the failure is in Claude Code's internal request path rather than the OS network stack.

Environment

  • OS: Windows
  • Claude Code version: 2.1.152
  • Install path:
C:\Users\xpeng\AppData\Roaming\npm\node_modules\@anthropic-ai\claude-code\bin\claude.exe
  • Endpoint type: Anthropic-compatible third-party endpoint
  • Base URL:
https://open.bigmodel.cn/api/anthropic
  • Model aliases configured to BigModel models:
ANTHROPIC_DEFAULT_HAIKU_MODEL=glm-4.7
ANTHROPIC_DEFAULT_SONNET_MODEL=glm-5
ANTHROPIC_DEFAULT_OPUS_MODEL=glm-5.1

Reproduction

From a standalone Windows PowerShell, run:

claude -p "只回复 OK"

Expected:

OK

Actual:

API Error: Unable to connect to API (ConnectionRefused)

The debug log shows repeated retries:

[API REQUEST] /api/anthropic/v1/messages source=sdk
[ERROR] API error (attempt 1/11): undefined Connection error.
...
[ERROR] Connection error details: code=ConnectionRefused, message=Unable to connect. Is the computer able to access the url?
[ERROR] API connection_error after retries: Connection error.

What has been ruled out

OS/network reachability works

PowerShell/.NET can reach the endpoint:

HEAD https://open.bigmodel.cn/api/anthropic -> 200
POST https://open.bigmodel.cn/api/anthropic/v1/messages without auth -> 401

Plain Node.js can also reach the endpoint:

Node version: v22.17.0
HTTPS_PROXY exists: false
ALL_PROXY exists: false
NODE_OPTIONS: <not set>
HEAD lookup: host=open.bigmodel.cn, address=60.205.172.105, family=4
HEAD tcp connect: local=<local-ip>:<port>, remote=60.205.172.105:443
HEAD tls secureConnect: authorized=true, authorizationError=
HEAD https://open.bigmodel.cn/api/anthropic: status=200
POST lookup: host=open.bigmodel.cn, address=60.205.172.105, family=4
POST tcp connect: local=<local-ip>:<port>, remote=60.205.172.105:443
POST tls secureConnect: authorized=true, authorizationError=
POST https://open.bigmodel.cn/api/anthropic/v1/messages: status=401

The 401 is expected because the probe intentionally did not include authentication. It confirms the request reaches the upstream API.

No proxy blackhole evidence

Checked:

  • Process/User/Machine HTTP_PROXY, HTTPS_PROXY, ALL_PROXY
  • WinHTTP proxy
  • WinINet proxy
  • hosts file
  • registry search
  • pktmon capture

No real 127.0.0.x:9 packet line was found after strict packet-line analysis.

Firewall/WFP did not identify a matching blocker

Checked Windows Firewall and WFP filters for:

codex, sandbox, openai, claude, node, 127.0.0.x

No matching rule/filter was found that would explain independent claude.exe failure.

CA store does not appear to be the cause

Running with:

$env:CLAUDE_CODE_CERT_STORE="system"
claude -p "只回复 OK"

Debug log confirms:

CA certs: stores=system
CA certs: Loaded 76 system CA certificates

But the same ConnectionRefused still occurs.

npm shim, plugins, hooks, slash commands are not the cause

The following all fail with the same ConnectionRefused:

claude -p "只回复 OK"
claude --disable-slash-commands -p "只回复 OK"
claude --bare -p "只回复 OK"
C:\Users\xpeng\AppData\Roaming\npm\node_modules\@anthropic-ai\claude-code\bin\claude.exe -p "只回复 OK"
C:\Users\xpeng\AppData\Roaming\npm\node_modules\@anthropic-ai\claude-code\bin\claude.exe --bare -p "只回复 OK"

Workaround that succeeds

A local Node HTTP proxy forwarding to the same upstream endpoint works:

Claude Code
  -> http://127.0.0.1:8787/api/anthropic
  -> local Node https.request proxy
  -> https://open.bigmodel.cn/api/anthropic

With this workaround:

claude --settings <temporary-settings-pointing-to-local-proxy> -p "只回复 OK"

Claude Code returns:

OK

Proxy log:

POST /api/anthropic/v1/messages?beta=true => https://open.bigmodel.cn/api/anthropic/v1/messages?beta=true -> 200

This strongly suggests the upstream API and credentials are usable, and that the failure is specific to Claude Code's direct upstream request path.

Expected behavior

Claude Code should be able to call the configured Anthropic-compatible endpoint directly, just as plain Node.js https.request can.

Actual behavior

Claude Code's direct request path fails with:

ConnectionRefused

while the same endpoint works through PowerShell, plain Node.js, and a local Node proxy.

Related issue

This appears similar to:

https://github.com/anthropics/claude-code/issues/53346

Notes

No API key, bearer token, authorization header, or credential is included in this report.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗