Claude Code "Unable to Connect to API": ECONNREFUSED, ENOTFOUND and ECONNRESET

What Unable to connect to API. Check your internet connection means, whether to wait, and what to check first.

Language: English · 日本語版

Fix a setting, login or environment Official documentation checked on

Wait or fix?

Fix the connection path; waiting helps only for brief drops. The TCP connection to the API failed or never completed. Claude Code retries intermittent failures automatically, so if the message stays, something between your terminal and api.anthropic.com is in the way. One curl command tells you which side to look at: if curl fails too, it is the network, VPN or proxy; if curl succeeds, it is usually a setting that only Claude Code reads.

Messages you may see

  • Unable to connect to API. Check your internet connection
  • Connection refused — a firewall or proxy may be blocking it (ConnectionRefused)
  • Can't reach the API server — check your internet or DNS (ENOTFOUND)
  • Connection dropped (ECONNRESET)

The exact wording changes a little between Claude Code versions and providers.

What the message means

For the common connection error codes, the message names the kind of failure and keeps the code in parentheses: Connection refused (ConnectionRefused or ECONNREFUSED), Can't reach the API server (ENOTFOUND), No internet route (EHOSTUNREACH), Couldn't connect through your proxy (ERR_PROXY_TUNNEL) and Connection dropped (ECONNRESET). Before v2.1.227, each of these read "Unable to connect to API" followed by the code. The official reference lists the common causes as no internet access, a VPN that blocks api.anthropic.com, or a required corporate proxy that is not configured.

Common causes

  • No internet access, or a VPN that blocks api.anthropic.com.
  • A corporate proxy that is required but not configured.
  • A leftover ANTHROPIC_BASE_URL in the shell or in the env block of a settings file, pointing at a local proxy or gateway that is no longer running.
  • A broken resolver in /etc/resolv.conf on Linux and WSL, a stale VPN tunnel interface on macOS, or a container runtime such as Docker Desktop intercepting outbound traffic.

Check in this order

  1. From the same shell, run curl -I https://api.anthropic.com. In PowerShell, use curl.exe -I https://api.anthropic.com so the built-in alias is not used.
  2. If curl fails: check your internet and VPN. Behind a corporate proxy, set HTTPS_PROXY before launching Claude Code, and make sure the firewall allows the hosts listed in the network access requirements.
  3. If curl succeeds: run echo $ANTHROPIC_BASE_URL (PowerShell: echo $env:ANTHROPIC_BASE_URL) and look for it in the env block of your settings files. Remove a leftover value and start Claude Code from a new terminal.
  4. If it still fails: on Linux and WSL, check /etc/resolv.conf for an unreachable nameserver; on macOS, check ifconfig for stale utun interfaces from a removed VPN; quit Docker Desktop or similar runtimes and retry.
  5. If you route through a gateway on purpose and every request ends in "Connection dropped", check that the gateway and its upstream accept tool search fields.

We took the fixes from the official pages below and put them in order, with the quickest and most likely ones first.

How it differs from similar errors

  • An SSL certificate verification error means a proxy or security appliance is intercepting TLS with its own certificate. The fix there is NODE_EXTRA_CA_CERTS or the system certificate store.
  • "Unable to connect to Anthropic services" comes from the connectivity check during first-run setup, before the sign-in step.
  • 401, 403 and 429 mean the API did answer, so the network path works.

Related errors

Official sources

Unofficial page. Not affiliated with, endorsed by, or sponsored by Anthropic, PBC. Claude and Claude Code are trademarks of Anthropic, PBC. Messages and fixes change with updates, so read the official pages as well.

Back to the error list (10 errors)