Answer: Confirm you can reach the API host from the same shell by running `curl -I https://api.anthropic.com` (on Windows PowerShell use `curl.exe -I https://api.anthropic.com`), and if you are behind a corporate proxy, set `HTTPS_PROXY` before launching Claude Code. If you route through an LLM gateway or relay, set `ANTHROPIC_BASE_URL` to its address, and ensure your firewall allows the required hosts. Status: Confirmed Entry: tool/claude-code/troubleshooting/fix-unable-to-connect-to-api Revision: 3 Digest: sha256:1651202c93cb22c5 (changes whenever the content changes) Timeline: Created: 2026-11-13T03:04:06Z Last changed: 2026-11-16T12:08:50Z (PowerShell curl command: — → curl.exe -I https://api.anthropic.com) Last verified: 2026-11-20T12:20:35Z Next check: 2026-11-21T12:20:35Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of curl check command | curl -I https://api.anthropic.com | [1] | 2026-11-20 PowerShell curl command | curl.exe -I https://api.anthropic.com | [1] | 2026-11-20 proxy environment variable | HTTPS_PROXY | [1] | 2026-11-20 gateway base URL variable | ANTHROPIC_BASE_URL | [1] | 2026-11-20 version before which coded messages differed | v2.1.227 | [1] | 2026-11-20 version before which tool search was off behind a gateway | v2.1.304 | [1] | 2026-11-20 Sources: [1] Anthropic. "Error reference". https://code.claude.com/docs/en/errors.md Role: primary. Accessed: 2026-11-20T12:20:35Z Quote: "Confirm you can reach the API host from the same shell by running `curl -I https://api.anthropic.com`." (Supports: curl check command) Quote: "On Windows PowerShell use `curl.exe -I https://api.anthropic.com` so the built-in `Invoke-WebRequest` alias is not used." (Supports: PowerShell curl command) Quote: "If you are behind a corporate proxy, set `HTTPS_PROXY` before launching Claude Code" (Supports: proxy environment variable) Quote: "If you route through an LLM gateway or relay, set [`ANTHROPIC_BASE_URL`](https://code.claude.com/docs/en/env-vars) to its address." (Supports: gateway base URL variable) Quote: "Before v2.1.227, each of these coded messages read `Unable to connect to API` followed by the code" (Supports: version before which coded messages differed) Quote: "Before v2.1.304, tool search was off behind a gateway unless you turned it on with `ENABLE_TOOL_SEARCH`." (Supports: version before which tool search was off behind a gateway) Published: 2026-11-20T10:25:18Z Snapshot SHA-256: c9ad601aff1e6a50d95382b7c498d9da861c091898ac54ec614418bd376887f4 (captured 2026-11-20T12:20:34Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. Cross-check: not-available at 2026-11-20T12:20:35Z. No independent second source is configured for this entry Last successful check: 2026-11-20T12:20:35Z Last attempt: 2026-11-20T12:20:35Z Notes and limitations: Extracted automatically from a single official source (section "Unable to connect to API"). Related: https://latestn.com/tool/claude-code/troubleshooting/fix-unable-to-locate-package How do I fix the 'Unable to locate package claude-desktop' error when installing on Linux? https://latestn.com/tool/claude-code/troubleshooting/fullscreen-stale-text How do I fix stale or misplaced text on screen in Claude Code fullscreen mode? https://latestn.com/tool/claude-code/troubleshooting/gcp-gateway-troubleshooting How do I troubleshoot problems when running Claude apps gateway on Google Cloud? https://latestn.com/tool/claude-code/troubleshooting/fix-plugin-installed-not-working How do I fix a Claude Code plugin that is installed but not working or not showing up? https://latestn.com/tool/claude-code/troubleshooting/fix-plugin-not-found-in-marketplace Why does Claude Code say a plugin is not found in the marketplace, and how do I fix it? https://latestn.com/tool/claude-code/troubleshooting/fix-slow-search-wsl How do I fix slow or incomplete search results in Claude Code on WSL? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-16T12:08:50Z | changed | PowerShell curl command: — → curl.exe -I https://api.anthropic.com | [1] 2026-11-16T12:08:50Z | changed | curl check command: — → curl -I https://api.anthropic.com | [1] 2026-11-16T12:08:50Z | changed | PowerShell command: curl.exe -I https://api.anthropic.com → — | [1] 2026-11-16T12:08:50Z | changed | diagnostic command: curl -I https://api.anthropic.com → — | [1] 2026-11-13T12:10:18Z | changed | version before which tool search was off behind a gateway: — → v2.1.304 | [1] 2026-11-13T12:10:18Z | changed | PowerShell command: — → curl.exe -I https://api.anthropic.com | [1] 2026-11-13T12:10:18Z | changed | diagnostic command: — → curl -I https://api.anthropic.com | [1] 2026-11-13T12:10:18Z | changed | version before which tool search was off behind gateway: v2.1.304 → — | [1] 2026-11-13T12:10:18Z | changed | PowerShell curl command: curl.exe -I https://api.anthropic.com → — | [1] 2026-11-13T12:10:18Z | changed | curl check command: curl -I https://api.anthropic.com → — | [1] 2026-11-13T03:04:06Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/claude-code/troubleshooting/fix-unable-to-connect-to-api/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/claude-code/troubleshooting/fix-unable-to-connect-to-api POST: https://latestn.com/dispute/tool/claude-code/troubleshooting/fix-unable-to-connect-to-api with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/claude-code/troubleshooting/fix-unable-to-connect-to-api?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I fix the Claude Code "Unable to connect to API" network error? Revision 3, last verified 2026-11-20T12:20:35Z. https://latestn.com/tool/claude-code/troubleshooting/fix-unable-to-connect-to-api (accessed 2026-11-21T10:02:41Z). @misc{LatestN_tool_claude_code_troubleshooting_fix_unable_to_connect_to_api_r3, title = {How do I fix the Claude Code "Unable to connect to API" network error?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/claude-code/troubleshooting/fix-unable-to-connect-to-api}}, note = {Revision 3; digest sha256:1651202c93cb22c5; last verified 2026-11-20T12:20:35Z; accessed 2026-11-21T10:02:41Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/claude-code/troubleshooting/fix-unable-to-connect-to-api