Hier ist eine Description, direkt im Format der anderen.../
Bug Description
Hier ist eine Description, direkt im Format der anderen Issues, die du oben gesehen hast:
Bug Description
Claude Code CLI fails on every request with Unable to connect to API (ConnectionRefused), retrying 10x before giving up. The Claude Desktop app on the same machine, same network, works normally at the same time. Started suddenly, no local network/firewall/VPN changes.
Environment Info
Platform: macOS (darwin), Apple Silicon
Claude Code Version: 2.1.199
Installation method: Standalone installer (curl -fsSL https://claude.ai/install.sh | sh)
Terminal: zsh
Plan: Claude Max (Opus 4.8, 1M context)
Steps to Reproduce
Launch claude in terminal
Enter any prompt (e.g. "hallo")
Immediately get Unable to connect to API (ConnectionRefused), retries, fails after 10 attempts
Network Diagnostics (all clean)
curl -4 -v https://api.anthropic.com/v1/messages → HTTP/2 405 (expected), Cloudflare responds normally
curl -6 -v https://api.anthropic.com/v1/messages → same, clean
DNS resolves correctly: 160.79.10
No proxy env vars set (env | grep -iE proxy empty)
No proxy overrides in ~/.claude.json or ~/.claude/settings.json
sudo lsof -i -P shows the claude process does establish a TCP connection to 160.79.104.10:443 (ESTABLISHED)
Fresh reinstall via standalone installer did not resolve it
~/.claude cache reset did not resolve it
Debug Log Excerpt
[DEBUG] [API:auth] OAuth token check complete
[DEBUG] [API REQUEST] /v1/messages source=count_tokens
[ERROR] countTokens API call failed: Connection error.
[DEBUG] countTokensWithFallback: [REDACTED] returned null, trying haiku fallback
Auth succeeds, request is dispatched, but fails with "Connection error" within ~400ms — consistent with the CLI's Bun-based HTTP client, not an actual network-level connection issue, since system-level curl to the same endpoint always succeeds and a TCP connection is visibly established via lsof at the same time.
Expected Behavior
Claude Code should connect to the API and respond normally, matching the working behavior of the Desktop p on the same machine/network.
What I've Already Ruled Out
Proxy/VPN (none present, env clean)
DNS (resolves correctly)
IPv4/IPv6 (both tested clean via curl)
Firewall/Little Snitch-style blocking (TCP connection to correct IP is ESTABLISHED per lsof)
Base URL override / stale config (no anomalies in ~/.claude.json)
Stale installation / version conflict (which -a claude clean, single install path, latest version)
Environment Info
- Platform: darwin
- Terminal: cursor
- Version: 2.1.199
- Feedback ID: 9855f0c1-9be2-4cb6-b655-bcbbe0407911
Errors
[]