Skillforge Field notes on shipping with AI tools

claude doctor API Connectivity: Read the Network Check

claude-codetroubleshooting

Since Claude Code 2.1.331, claude doctor ends its environment report with an "API connectivity" block. It probes the API host and the sign-in host from the shell you ran it in, and prints the HTTP status or the error for each. That makes it the quickest way to tell a proxy, firewall or DNS problem from a Claude Code problem, without starting a session.

Verified against: Claude Code 2.1.331 on 2026-11-24, inside a managed cloud session. Every output below was produced by running claude doctor with a scratch HOME and the environment variable changes named in each case. The changelog (raw GitHub) and the network-config, errors and CLI reference pages on code.claude.com were fetched the same day. We did not test a TLS-inspecting proxy, mTLS with a real certificate, or a real Bedrock or Vertex setup.

What a healthy run looks like

API connectivity
- API (api.anthropic.com): answered HTTP 200 in 33 ms
- Sign-in (platform.claude.com) via https_proxy: answered HTTP 200 in 398 ms
- ANTHROPIC_BASE_URL: set to an Anthropic host · NODE_EXTRA_CA_CERTS: set · CLAUDE_CODE_CLIENT_CERT: not set
  • API line: the host Claude Code sends model requests to, with the status and latency. Once ANTHROPIC_BASE_URL points elsewhere, the host is printed as custom host rather than by name.
  • Sign-in line: platform.claude.com, the host used for sign-in and token refresh.
  • via https_proxy: appears on a line only when that probe went through a proxy. The two probes can differ: in our run only the sign-in probe was proxied, because the environment's NO_PROXY listed api.anthropic.com but not platform.claude.com. With NO_PROXY and the proxy variables all unset, neither line said via.
  • Last line: a one-line summary of whether a base URL, extra CA file and client certificate are set. It reports set or not set, not whether the files are valid.

Failures we reproduced

| What we changed | Line printed | | - | - | | ANTHROPIC_BASE_URL=http://127.0.0.1:9 | API (custom host): failed after 1 ms: Connection refused, a firewall or proxy may be blocking it (ECONNREFUSED) | | ANTHROPIC_BASE_URL=https://example.invalid (through the proxy) | failed after 277 ms: Couldn't connect through your proxy (ERR_PROXY_TUNNEL), the proxy refused the tunnel: check its credentials and that it allows this host | | ANTHROPIC_BASE_URL=https://example.com, no proxy | failed after 2 ms: Can't reach the API server, check your internet or DNS (ENOTFOUND) | | ANTHROPIC_BASE_URL=https://api.anthropic.com/nonexistent | API (api.anthropic.com): answered HTTP 404 in 31 ms (expected 200) | | https_proxy=http://127.0.0.1:9 and NO_PROXY=api.anthropic.com | Sign-in (platform.claude.com) via https_proxy: failed after 1 ms: ECONNREFUSED |

The tool prints a long dash after the message in some of these lines; we replaced it with a comma here. Failed lines are followed by a generic hint: "A proxy, firewall, VPN or security software between this machine and the host can cause these results", with a link to the network-config page.

Two details worth knowing. A non-200 answer is reported as a failure against an expected 200, so a gateway that answers the probed path with something other than 200 would presumably be flagged too (hypothesis, not tested). And the base-URL probe hits the URL you configured, so a path in ANTHROPIC_BASE_URL is part of the test.

When it says "Not tested"

Instead of probing, the block can print one line. We saw two forms:

- Not tested: this session uses a cloud provider or a gateway, or your settings name a gateway, not the Anthropic API

We got this with CLAUDE_CODE_USE_BEDROCK=1 and separately with CLAUDE_CODE_USE_VERTEX=1. So the check says nothing about Bedrock or Vertex reachability. For those, test the provider endpoint yourself.

- Not tested: your organization's latest settings did not load (their fetch failed: network error), and they may forbid this test. ...

We got this with a dead proxy (https_proxy=http://127.0.0.1:9, NO_PROXY unset) and, with a different cause, authentication rejected (401) when ANTHROPIC_API_KEY held a bogus value. The session we ran in loads remote managed settings, so the check is skipped when that fetch fails. Whether a machine with no managed settings would instead run the probes and show the proxy error is a hypothesis; we did not confirm it. If you are not under managed settings, test it with the proxy variable pointed at a dead port and see which line you get.

Things it does not check

  • Proxy variable casing. Claude Code uses the first proxy variable set, in the order https_proxy, HTTPS_PROXY, http_proxy, HTTP_PROXY (network-config page). With both lowercase and uppercase set to different values, the lowercase one won in our runs (setting only HTTPS_PROXY to a dead port changed nothing). Check for a stale lowercase variable first.
  • CA file problems. With NODE_EXTRA_CA_CERTS=/nonexistent.pem, the connectivity block still reported HTTP 200 and NODE_EXTRA_CA_CERTS: set. The doctor summary does not prove the file loaded. The network-config page recommends claude --debug and looking for the CA certs: line in the log.
  • Exit status. claude doctor exited 0 in our run with ANTHROPIC_BASE_URL=http://127.0.0.1:9 and a failed probe, so do not gate a script on the exit code. Parse the output or run your own probe.
  • First-run check. The errors page describes a separate connectivity check during first-run setup (Unable to connect to Anthropic services) that exits on failure. That is a different code path with a 10 second timeout per probe.

A short triage order

  1. Run claude doctor in the same shell and environment where Claude Code fails.
  2. Read the API line. ECONNREFUSED or ENOTFOUND means the address is wrong or unreachable. ERR_PROXY_TUNNEL means your proxy is up but refuses the host, so ask whoever runs it to allow it.
  3. Check which variables are set with env | grep -i proxy, remembering the precedence order above.
  4. If it says "Not tested", the check cannot help for this setup: read the "Managed settings (remote)" and "Organization policy" lines above the block, or test your provider directly.
  5. For certificate problems, use claude --debug and read the log instead.

The same release added CLAUDE_CODE_DISABLE_RESPONSE_COMPRESSION, for proxies that cut compressed model responses off. As of 2026-11-24 it is in the changelog, which also says it is not advised yet for self-hosted runners or Remote Control, but the environment variables page has no entry for it. We did not test it, so treat the changelog line as the only source.

FAQ

Does claude doctor send anything to Anthropic? It makes the two probe requests shown in the block. The docs do not describe what the probes contain, so we cannot say more than that.

Is there a way to turn the connectivity section off? We found no documented switch in the CLI reference or network-config page.

Does this replace /doctor in a session? No. The CLI reference describes claude doctor as read-only diagnostics that run without starting a session, and /doctor as the in-session checkup that can apply fixes.