Vũ Văn HảiFull-stack · AI-native
GuidesBlog
Discuss a project

© 2026 Vu Van Hai · Written from real deployment experience.

HomeGuidesBlogRSS
  1. Guides
  2. /Dev tools
  3. /Fix Claude Code connection errors on Windows (ECONNREFUSED, Bun crash)

Fix Claude Code connection errors on Windows (ECONNREFUSED, Bun crash)

Fully resolve two common Claude Code errors on Windows - can't connect to the API (ECONNREFUSED) and a Bun crash (Internal assertion failure) - by removing the NPM build, clearing config caches, and installing the Native Stable build.

Updated: Sep 21, 20263 min read
Claude CodeWindowsNetworking
On this page
  • Quick reference
  • Step by step
  • Step 1: Remove the NPM build (deprecated)
  • Step 2: Clear the cache and config files
  • Step 3: Install the Native Stable build
  • Troubleshooting / notes

Two common errors when installing and using Claude Code on Windows are being unable to reach the API (Unable to connect to API: ECONNREFUSED when you run a prompt) and a native compiler crash (Bun has crashed: Internal assertion failure). The full fix: remove the deprecated NPM install, clear the old caches/config, then reinstall using the Native Stable build.

Quick reference

Open PowerShell and run these commands in order.

  1. Remove the old NPM install (if any):

    npm uninstall -g @anthropic-ai/claude-code
  2. Delete the broken config and cache files:

    Remove-Item -Path "$env:USERPROFILE\.claude" -Recurse -Force
    Remove-Item -Path "$env:USERPROFILE\.claude.json" -Force
    Remove-Item -Path ".claude" -Recurse -Force
    Remove-Item -Path ".mcp.json" -Force
  3. Reinstall with the Native Stable build:

    & ([scriptblock]::Create((irm https://claude.ai/install.ps1))) stable

Step by step

Step 1: Remove the NPM build (deprecated)

Originally many people installed Claude Code through Node.js (npm install -g @anthropic-ai/claude-code). Anthropic's docs now mark this as deprecated. Running via Node.js on Windows often causes local port-resolution problems - most typically the ECONNREFUSED error mid-prompt when the connection to the local server drops.

Remove the old build from NPM:

npm uninstall -g @anthropic-ai/claude-code

Step 2: Clear the cache and config files

When you move from NPM to the native build (compiled with the Bun core), the old JSON/YAML config format may be incompatible. When Bun tries to read that file it can crash with: panic: Internal assertion failure - Bun has crashed... yaml_parse(500).

To avoid leftovers from the old install, delete all the config cache (note: your old terminal chat history will be lost and the tool returns to its default state).

For your user account's home folder:

Remove-Item -Path "$env:USERPROFILE\.claude" -Recurse -Force
Remove-Item -Path "$env:USERPROFILE\.claude.json" -Force

If there's a config file in the project folder where you opened PowerShell:

Remove-Item -Path ".claude" -Recurse -Force
Remove-Item -Path ".mcp.json" -Force

Step 3: Install the Native Stable build

The native build (a standalone .exe) runs lighter and skips the OS dependency. To avoid a too-new Latest build hitting a Bun compiler bug on Windows (for example v2.1.100), it's best to pin to the Stable channel:

& ([scriptblock]::Create((irm https://claude.ai/install.ps1))) stable

To update to the latest preview build later, drop the stable word and use irm https://claude.ai/install.ps1 | iex.

Troubleshooting / notes

  • Rule out a proxy: sometimes the ECONNREFUSED error comes from an HTTP agent forced onto the Windows terminal. Check for hidden proxy environment variables with $env:HTTP_PROXY or $env:HTTPS_PROXY, and clear them like $env:HTTP_PROXY="" if you find a stray proxy.
  • Extra system requirement: running claude with the native build doesn't need Administrator, but the machine must have Git for Windows installed, because Claude quietly uses its bundled Bash emulation library.
SymptomFix
ECONNREFUSED when running a promptRemove the NPM build, install Native Stable; check $env:HTTP_PROXY and $env:HTTPS_PROXY
Bun has crashed: Internal assertion failureDelete the old .claude, .claude.json, then reinstall the native build
The claude command won't runInstall Git for Windows (Claude needs its bundled Bash emulation)
PreviousDebug and bypass SSL pinning on an Android emulatorNextA dedicated Chrome for chrome-devtools-mcp that can sign in

Related articles

  • Token accounting for AI agents: tokens, context windows, and caching from first principles

    A model has no memory - everything that looks like memory is your code resending it. Get that one sentence right and you understand tokens, context windows, and prompt caching, and why an agent's bill balloons.

  • Clone a PostgreSQL database from a VPS to local Windows

    Make a full copy (schema and data) of a PostgreSQL database on a VPS onto a Windows dev machine using an SSH tunnel, pg_dump and pg_restore, including how to move the local PostgreSQL port out of the way.

    Database

    Database
  • Connect to PostgreSQL on a VPS through an SSH tunnel

    Use an SSH tunnel so your dev machine can reach PostgreSQL on a VPS without exposing port 5432 to the internet, plus the DATABASE_URL setup for local and production.

    Database

    Database

Written by Vu Van Hai

I'm Hai, a full-stack developer based in Ho Chi Minh City. These guides come from systems I built and run myself. Need to build or untangle something similar? Get in touch.

Discuss a projectMore guides

Spot a mistake or a command that no longer works? Let me know

On this page

  • Quick reference
  • Step by step
  • Step 1: Remove the NPM build (deprecated)
  • Step 2: Clear the cache and config files
  • Step 3: Install the Native Stable build
  • Troubleshooting / notes