[BUG] Unable to connect to API (ConnectionRefused) after uninstalling MCP tools — network and Node.js confirmed healthy

Status Fixed / completed
Reported on v2.1.210
Maintainer reply None cached
Activity 0 comments · opened Jul 16, 2026 · closed Jul 17, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Claude Code fails with "Unable to connect to API (ConnectionRefused)" on every prompt, both in interactive mode and with claude -p, on Windows 11.

Context: The day before, I uninstalled several third-party MCP tools (headroom, serena, rtk) and used CCleaner. The failure started right after.

Diagnostics already performed, all ruled out as the cause:

  • TCP/TLS connectivity to api.anthropic.com:443 works (Test-NetConnection OK, IP resolves correctly)
  • Native Windows curl/WebRequest to the API connects and returns a valid HTTP response (404/405)
  • System Node.js (v24.16.0) tested in isolation with fetch() to api.anthropic.com/v1/messages correctly returns HTTP 405
  • No system proxy, no HTTPS_PROXY/ANTHROPIC_BASE_URL/NODE_EXTRA_CA_CERTS in environment variables (user or machine)
  • No suspicious entries in hosts file
  • Windows Firewall has no blocking rules for claude.exe/node.exe
  • No third-party antivirus
  • Winsock reset and PC rebooted
  • settings.json, settings.local.json, and mcp.json cleaned of leftover configuration (local proxy 127.0.0.1:8787 from the uninstalled headroom tool, broken hooks)
  • Full clean reinstall of Claude Code (winget uninstall + winget install), including deleting the ~/.claude folder — the failure persists identically

Since system Node.js connects to the same URL without issue, but the claude.exe binary consistently fails, the problem appears to be isolated to the binary's internal runtime, rather than network, DNS, TLS, or Claude Code configuration.

What Should Happen?

Claude Code should connect to the Anthropic API and respond to prompts normally, given that network connectivity and Node.js itself are confirmed working on the same machine.

Error Messages/Logs

API Error: Unable to connect to API (ConnectionRefused)

Steps to Reproduce

  1. Uninstall third-party MCP tools (headroom, serena, rtk) that had modified ~/.claude/settings.local.json and ~/.claude/mcp.json
  2. Run CCleaner
  3. Launch claude or run claude -p "hello"
  4. Error appears immediately: "Unable to connect to API (ConnectionRefused)"
  5. Persists even after full clean reinstall of Claude Code and deletion of ~/.claude folder

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

yesterday morning

Claude Code Version

2.1.210

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

PowerShell

Additional Information

Full network diagnostics available on request. Suspect this may be related to similar reports: #16331, #17541, #56242, #76847 — where curl/native network succeeds but Claude Code's internal HTTP client fails with the same symptom.

View original on GitHub ↗