◉CLAUDE LABJP
●CC 2.1.331 — 2.1.331 adds an API connectivity check to claude doctor and fixes MCP tool calls hanging for up to 30 minutes●SONNET 4.5 — Sonnet 4.5 retires from the Claude API on 11/30, 6 days left. Move to claude-sonnet-5-5●OFFICE — Users report the Microsoft 365 add-in disappearing seconds after install on macOS●NEW — New: Count how many input tokens one more tool costs with count_tokens●GEMINI 2.5 — Using Gemini 2.5 alongside Claude? From 12/1 requests reroute to newer models, billed at their rates. 7 days left●WORKBENCH — Trying the API in Workbench for the first time? Check the billing pages before you start●CC 2.1.331 — 2.1.331 adds an API connectivity check to claude doctor and fixes MCP tool calls hanging for up to 30 minutes●SONNET 4.5 — Sonnet 4.5 retires from the Claude API on 11/30, 6 days left. Move to claude-sonnet-5-5●OFFICE — Users report the Microsoft 365 add-in disappearing seconds after install on macOS●NEW — New: Count how many input tokens one more tool costs with count_tokens●GEMINI 2.5 — Using Gemini 2.5 alongside Claude? From 12/1 requests reroute to newer models, billed at their rates. 7 days left●WORKBENCH — Trying the API in Workbench for the first time? Check the billing pages before you start
Articles/Claude Code
⟐ Claude Code/2026-11-24Intermediate

When Claude Code Can't Connect, Read the Two Lines in claude doctor's API Connectivity Section Side by Side

Claude Code 2.1.331 added an API connectivity section to claude doctor. Using real output from a machine behind a proxy, this walks through reading the API and Sign-in lines together, what "via https_proxy" tells you, ERR_PROXY_TUNNEL versus ECONNREFUSED, and a small script that adds a first guess.

Claude Code292claude doctorProxyNetworking3Troubleshooting30

On Tuesday afternoon I was reading the Claude Code 2.1.331 changelog when one line caught me: claude doctor now has an "API connectivity" section. It reports whether the API can be reached, with the HTTP status or the error — or says why it wasn't tested.

Until now, when something "couldn't connect," my routine was to fire off curl, then stare at env | grep -i proxy, then start suspecting certificates. It was slow, and worse, curl getting through never really proved that Claude Code would.

So I ran claude doctor on a work machine that sits behind a proxy, under a few deliberately broken settings, and lined up what came out. What I took away is simple: this section is much faster to read as a pair of lines than one line at a time. Here it is as a set of questions I actually had.

What does it show?

On 2.1.331 or later, the section sits in the middle of the claude doctor output. With nothing changed, mine looked like this:

API connectivity
- API (api.anthropic.com): answered HTTP 200 in 45 ms
- Sign-in (platform.claude.com) via https_proxy: answered HTTP 200 in 90 ms
- ANTHROPIC_BASE_URL: set to an Anthropic host · NODE_EXTRA_CA_CERTS: set · CLAUDE_CODE_CLIENT_CERT: not set
  • The first line is the API host your model calls go to.
  • The second is platform.claude.com, used for sign-in.
  • The third only says whether ANTHROPIC_BASE_URL and the extra certificate settings are set. It doesn't check what's in them.

Which line should I look at first?

Neither on its own. The API and sign-in are different hosts, and they can take different routes. If only one fails, the problem is that route, not the whole machine.

I pointed the proxy variables at a port nothing listens on, and got this:

- API (api.anthropic.com): answered HTTP 200 in 36 ms
- Sign-in (platform.claude.com) via https_proxy: failed after 0 ms: ECONNREFUSED

My first thought was "if the proxy is dead, both should fail." Then I noticed that only the sign-in line says via https_proxy. On this machine the API traffic wasn't going through the proxy at all. "via" tells you which route each line took, and depending on what's in NO_PROXY, the same proxy setting can apply to one host and not the other.

What's the difference between ERR_PROXY_TUNNEL and ECONNREFUSED?

Next I set ANTHROPIC_BASE_URL to a host name that doesn't exist — think of a gateway URL with a typo:

- API (custom host) via https_proxy: failed after 317 ms: Couldn't connect through your proxy (ERR_PROXY_TUNNEL) — the proxy refused the tunnel: check its credentials and that it allows this host

I expected a DNS error. But behind a proxy, it's the proxy that resolves the name, so what surfaces is the proxy refusing the tunnel. Pointing the base URL at a closed local port (http://127.0.0.1:9) instead gave:

- API (custom host): failed after 3 ms: Connection refused — a firewall or proxy may be blocking it (ECONNREFUSED)
  • ERR_PROXY_TUNNEL: you reached the proxy, and it refused to go further. Check the host spelling and the proxy's allowlist first.
  • ECONNREFUSED: the other end (or the proxy you named) isn't accepting connections. Check the port and whether it's running.

The error name tells you where it stopped; "via" tells you which way it went. Reading those two separately is what turned my questions to whoever runs the proxy into one-liners.

Is "answered HTTP 401" a failure?

Not a network one. "answered" means an HTTP reply came back, so a 401 or 403 means the route works and you're stopped at authentication or permissions. I used to lump every non-200 into "can't connect," and more than once spent half an hour on proxy settings for what turned out to be an expired key. My rule now: "answered" clears the route; "failed" means suspect the route. For the auth side, I wrote up the credential order to check when only claude -p refuses to log in.

If the third line says "set", am I fine?

Not necessarily. I pointed NODE_EXTRA_CA_CERTS at a file that doesn't exist, and the line still said set while both checks returned 200 — this machine simply didn't need the extra certificate. On a network that really does need a corporate CA, the same mistake could fail both checks while the third line still reads set. I treat it as a list of variables to open and check myself.

I get 200, but long replies get cut off

2.1.331 also adds CLAUDE_CODE_DISABLE_RESPONSE_COMPRESSION, for proxies that cut compressed responses short. The changelog notes it isn't advised yet for self-hosted runners or Remote Control. With it set, the connectivity section looked exactly the same as without it, so I read a 200 there as "it got through," not "long replies will arrive whole." Connectivity passes but long replies break off — that's the combination where this variable is worth trying.

Reading this by eye every time is tedious

As an indie developer moving between the machine I use for my wallpaper apps and the one I use to maintain websites, I end up running the same check over and over. So I keep a small script that pulls out just this section and adds a one-line first guess. I ran it under the three settings above and got the expected guess each time.

#!/usr/bin/env bash
# doctor-net.sh — print claude doctor's "API connectivity" section and a first guess from the two lines
set -u
out="$(timeout 90 claude doctor 2>&1)" || true
sec="$(printf '%s\n' "$out" | sed -n '/^API connectivity/,/^$/p')"
if [ -z "$sec" ]; then
  # Versions before 2.1.331 don't have this section at all
  echo "No API connectivity section: $(claude --version 2>/dev/null)"
  exit 2
fi
printf '%s\n' "$sec"
 
api="$(printf '%s\n' "$sec" | grep -m1 '^- API ')"
signin="$(printf '%s\n' "$sec" | grep -m1 '^- Sign-in ')"
# "answered" means an HTTP reply arrived; a 401 or 403 still means the route works
reached() { printf '%s' "$1" | grep -q 'answered HTTP'; }
 
echo "---"
if reached "$api" && reached "$signin"; then
  echo "Guess: both routes work. If the status isn't 2xx, look at auth or permissions"
elif reached "$api"; then
  echo "Guess: API reached, sign-in failed. Check the sign-in route (look for 'via')"
elif reached "$signin"; then
  echo "Guess: sign-in reached, API failed. Check ANTHROPIC_BASE_URL and its route"
else
  echo "Guess: both failed. Start with this machine's network itself"
fi
case "$api $signin" in
  *ERR_PROXY_TUNNEL*) echo "Note: the proxy refused the tunnel. Check the host spelling and the proxy's allowlist" ;;
  *ECONNREFUSED*)     echo "Note: the other end (or proxy) refused the connection. Check the port and that it's running" ;;
esac

I only check for answered HTTP because I'd rather leave the status to a human; sorting 401 into "failure" automatically would just have the script repeat my old detour. Printing the version when the section is missing keeps an older install's silence from reading as "all clear."

When the section isn't there or doesn't settle it, I go back to following a connection error down through DNS, proxy, certificate and timeout. If it shows up alongside other doctor warnings, the day I sorted four warnings by cause may help.

One thing to try next

Next time something won't connect, confirm claude --version is 2.1.331 or later, run claude doctor, and copy down just the "via" and error names from the API and Sign-in lines. Those two lines tell the person who runs your proxy — and you — where to look. Pasting them is now the first thing I do before asking anyone.

Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

If you found this article helpful, a small tip ($1.50) would mean a lot to us. Your support helps keep this site ad-free and covers server and hosting costs.

Related Articles

⟐ Claude Code2026-11-22
When a Remote MCP Server Goes Silent After Its Token Expires, Check for mcp-remote First
A remote MCP tool call hangs with no error. How to tell an expired token from a slow tool, a script that finds servers bridged through mcp-remote, and how to switch to the native HTTP transport or cap the wait.
⟐ Claude Code2026-11-21
When Every New Desktop Session Creates a Worktree: Three Places to Check, and When It's Fine to Turn It Off
Claude Code Desktop keeps creating a worktree for every new session, and .claude/worktrees/ and claude/ branches pile up. Here is where the Worktree default actually gets turned on, when to keep it and when to skip it, and a SessionStart hook that tells you when a session is running inside a worktree.
⟐ Claude Code2026-11-06
When claude doctor Listed Four Warnings, I Sorted Them by Cause Before Fixing Anything
claude doctor ended with "4 warnings found", but I didn't need four fixes. Using the real output, here is how to spot duplicated warnings and sign-in-only info lines, group the rest by cause, and decide the order of repair.