Claude Code error
Claude Code: Unable to connect to API. Check your internet connection
Unable to connect to API. Check your internet connectionStatus: WorkaroundLast verified 4 documented fixes3 sources
What it means
The TCP connection to the API failed or never completed. Coded variants include Connection dropped (ECONNRESET), Can't reach the API server - check your internet or DNS (ENOTFOUND), and Couldn't connect through your proxy (ERR_PROXY_TUNNEL). Older versions showed API Error (Connection error.) or Unable to connect to API (ECONNREFUSED).
Causes
- No internet access
- A VPN that blocks api.anthropic.com
- A required corporate proxy that is not configured
- A leftover ANTHROPIC_BASE_URL pointing at a local proxy or gateway that is no longer running
- An unreachable nameserver in /etc/resolv.conf on Linux and WSL
- Stale VPN utun interfaces on macOS, or Docker Desktop intercepting outbound traffic
How to fix it
- Fix 1.
Confirm you can reach the API host from the same shell (on Windows PowerShell use curl.exe).
Terminalcurl -I https://api.anthropic.com - Fix 2.
If you are behind a corporate proxy, set HTTPS_PROXY before launching Claude Code, and ensure your firewall allows the hosts in Network access requirements.
- Fix 3.
Check whether ANTHROPIC_BASE_URL is set in your shell or the env block of your settings files; remove a leftover value and start Claude Code from a new terminal.
Terminalecho $ANTHROPIC_BASE_URL - Fix 4.
Intermittent failures are retried automatically; v2.1.198 made transient errors like ECONNRESET retry with backoff instead of failing the turn.
More Claude Code errors
All 18 Claude Code errorsAPI Error: 500 Internal server error. This is a server-side issue, usually temporaryStatus: WorkaroundAPI Error: Repeated 529 Overloaded errors. The API is at capacityStatus: WorkaroundAPI Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.5: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_01FRvEykWmCgrgJ22mvBbKhV. Each `tool_use` block must have a corresponding `tool_result` block in the next message."}}Status: OpenUnable to connect to API: SSL certificate verification failed (UNABLE_TO_GET_ISSUER_CERT_LOCALLY).Status: WorkaroundPlease run /login · API Error: 401 OAuth token has expiredStatus: WorkaroundOAuth error: timeout of 15000ms exceededStatus: OpenPrompt is too longStatus: WorkaroundYou've hit your session limit · resets 3:45pmStatus: By design
Related reading
- Composio CLI: Connect OpenClaw and Claude Code to 1,000+ AppsComposio CLI guide for Claude Code and OpenClaw: install, log in, and run the search, execute, link loop to connect agents to 1,000+ apps from one binary.
- Claude Code Idle Compaction: What It Does and How to Turn It OffClaude Code 2.1.299 compacts sessions over 200K tokens after about 54 idle minutes. How the cache math works, the setting to turn it off, and when to keep it.
- Claude Code Desktop SneakPeek Flaw: Fixed Version and What To DoSneakPeek (CVSS 8.7) let a poisoned HTML file read SSH keys and cloud credentials via the Claude Code Desktop preview pane. Fixed in Claude Desktop 1.30096.1.
- Reverse Engineer Anything (REA): What the MCP Server Does and Where the Line IsREA (Reverse Engineer Anything) is an MIT-licensed MCP server that lets Claude Code, Codex or Cursor inspect binaries, Electron apps and APKs. How to try it.
- Claude Code Projects: Coordinator, Threads, and LimitsClaude Code Projects is open to waitlisted Pro and Max users. How the coordinator and cloud threads work, what they cost in plan limits and where it breaks.
- Agent Harness Lessons From a 500B-Token Decompile: Give Agents a PASS/FAIL OracleAgent harness lessons from a 500B+ token decompile: a byte-matching PASS/FAIL oracle beat the reviewer agent. How agents cheated it and what to copy.
FAQ
What does "Unable to connect to API. Check your internet connection" mean in Claude Code?
The TCP connection to the API failed or never completed. Coded variants include Connection dropped (ECONNRESET), Can't reach the API server - check your internet or DNS (ENOTFOUND), and Couldn't connect through your proxy (ERR_PROXY_TUNNEL). Older versions showed API Error (Connection error.) or Unable to connect to API (ECONNREFUSED).
How do I fix "Unable to connect to API. Check your internet connection"?
There are 4 documented fixes. Start with the first: Confirm you can reach the API host from the same shell (on Windows PowerShell use curl.exe).
Is this Claude Code error fixed?
Status: Workaround. No release removes the cause. The documented fixes work around it. Affected versions: All versions. Message wording changed in v2.1.227 (before, each read Unable to connect to API followed by the code).
Sources
Last verified against 3 sources: official docs, maintainer replies and release notes.
Newsletter
Fixes for the tools you use, weekly
One email per week. New coding agent releases, what broke, and how developers are working around it.