Home › Claude Code › Errors › Connection errors
OverviewInstallCLI referencePricing & limitsAgent SDKSkills & pluginsGitHubWeb, desktop & IDEModelsErrorsOpen source?TutorialFor studentsQA automationvs Cursorvs Codex & OpenCodeSubagentsHooksMCPEcosystemVS CodeOpenRouterRate limits中文指南
Last updated: September 30, 2026

Claude Code connection errors: ECONNRESET, connection lost mid-response, "Waiting for API response", "Unable to connect to API", SSL certificate errors

These errors mean the request never completed: the TCP connection was reset, the TLS handshake failed, a proxy refused the host, or the stream simply went silent. Claude Code retries on its own, which is what the *Retrying in Ns · attempt x/y* and *Waiting for API response* lines are. The tracker shows two very different populations, and it matters which one you are in: local network problems that a proxy or CA setting fixes, and Anthropic-side incidents where the only fix is time.

TLDR

  • Retrying in 0s · attempt 1/10 / Waiting for API response · will retry in … — automatic retry in progress; the wait grows with each attempt.
  • Connection dropped (ECONNRESET) / Connection lost mid-response — the connection was cut; if raw curl works and there is no proxy, it is usually upstream.
  • Unable to connect to API / fetch failed / ConnectionRefused — nothing reached the endpoint: DNS, VPN, proxy, firewall.
  • unable to get local issuer certificate / CERT_HAS_EXPIRED — a TLS-inspecting proxy or a stale CA store; point NODE_EXTRA_CA_CERTS at the corporate root.

The messages

API Error: Connection dropped (ECONNRESET)
API Error: Connection lost mid-response
API Error: fetch failed
Unable to connect to API (ConnectionRefused)
Retrying in 0s · attempt 1/10
Waiting for API response · will retry in 2m 35s · check your network
API Error: Socket is closed
SSL certificate verification failed: unable to get local issuer certificate
Error: certificate has expired (CERT_HAS_EXPIRED)

Is it you or them? A two-minute check

curl -sS -o /dev/null -w "%{http_code} %{time_total}s\n" https://api.anthropic.com/v1/models -H "x-api-key: x" -H "anthropic-version: 2023-06-01"
# 401 in under a second = network path is fine, the problem is upstream or in Claude Code
# timeout / SSL error / 000 = the problem is on your side of the wire
env | grep -i -E "proxy|anthropic|node_extra|ssl"
claude --debug     # per-request timing and retry reasons in the log

If curl gets a fast 401 and there are no proxy variables, you are almost certainly looking at an upstream incident. That is the population in #87424 (open: intermittent ECONNRESET on the desktop app and the CLI, no VPN, no proxy, from August 13, confirmed by several people through August 21) and #86473 (persistent ECONNRESET on all surfaces while raw HTTP to the API works). Nothing local fixes those; retries and time do. Check status.claude.com, and if several people report the same hour on the tracker, stop debugging.

"Waiting for API response · check your network"

The message blames your network, and often it is wrong about that. #82155 (open, 15 reactions): multi-minute stalls all day with the retry backoff reaching over two minutes on a network that was demonstrably fine. #76555 (open): the wait on every single reply across models. #72059 and #70534: the same stall specifically when the advisor model is consulted, then a normal answer after the timer. The backoff is exponential, so the visible damage is the wait, not the failure; the variables below shorten it.

Retry and timeout variables

export CLAUDE_CODE_MAX_RETRIES=15               # default 10, capped at 15
export CLAUDE_CODE_RETRY_WATCHDOG=1              # keep retrying instead of giving up (unattended runs)
export API_TIMEOUT_MS=600000                     # per-request timeout, default 10 minutes
export CLAUDE_STREAM_FIRST_BYTE_TIMEOUT_MS=60000 # give up on a silent stream sooner and retry
export CLAUDE_CODE_MAX_TOOL_USE_CONCURRENCY=2    # fewer parallel streams on a flaky link

A lower first-byte timeout is the one that changes the feel of a flaky connection: instead of waiting the full ten minutes on a stream that will never answer, the client abandons it and retries. Lower tool-use concurrency helps on links that drop when several streams run at once (mobile hotspots, some VPNs).

Proxies, VPNs and corporate networks

  • Set the proxy variables Claude Code reads: HTTPS_PROXY (and HTTP_PROXY, NO_PROXY). A proxy that only exists in the browser or in npm config is invisible to the CLI.
  • TLS-inspecting proxies replace Anthropic's certificate with their own: that is unable to get local issuer certificate. Export the corporate root CA to a PEM file and set NODE_EXTRA_CA_CERTS=/path/to/corp-root.pem. Do not disable verification.
  • `CERT_HAS_EXPIRED` on the native build (#71727, 2.1.19x): the bundled trust store, not your clock. claude update; if stuck, the npm build uses the system store.
  • `ConnectionRefused` on macOS after a reinstall (#75897) — a local proxy or VPN client that is off, but still configured in the environment; clear the proxy variables and system proxy settings, then retry.
  • VPN exit changes mid-session reset every open stream: expect one ECONNRESET per reconnect.

Through a gateway

Point Claude Code at a gateway (ANTHROPIC_BASE_URL=https://aiprimetech.io) and the network path changes: the client talks to the gateway, and the gateway holds the upstream connections and retries a saturated account on another. It does not make a broken local network work, but for the *upstream reset* population above it removes the single-account dependency, and the same key keeps working through a subscription incident. Run the curl check against the gateway host to confirm the path before switching.

export ANTHROPIC_BASE_URL=https://aiprimetech.io
export ANTHROPIC_API_KEY=your_gateway_key
claude

Tired of fighting this one?

Run Claude Code through the AI Prime Tech gateway instead: the same Claude models on the gateway's own upstream accounts, two environment variables to switch, and new accounts get $5 in free API credit with code FIXIT — no card.

export ANTHROPIC_BASE_URL=https://aiprimetech.io
export ANTHROPIC_API_KEY=your_key

Create an account with code FIXIT

Frequently asked questions

How do I fix 'API Error: Connection dropped (ECONNRESET)' in Claude Code?

Run curl against the API: if it answers quickly and you have no proxy, the reset is upstream; let the retries run, check status.claude.com. If curl also fails, fix the proxy variables, VPN or CA certificate.

What does 'Waiting for API response · will retry in … · check your network' mean?

Claude Code got no answer from the API within the timeout and is backing off before retrying. Despite the wording it is often not your network; lower CLAUDE_STREAM_FIRST_BYTE_TIMEOUT_MS so the client abandons silent streams sooner.

How do I fix 'unable to get local issuer certificate' in Claude Code?

A proxy is re-signing TLS. Export the corporate root certificate as PEM and set NODE_EXTRA_CA_CERTS to that file. Never disable certificate verification.

What does 'Retrying in 0s · attempt 1/10' mean?

A request failed and Claude Code is retrying; the default is 10 attempts with growing delays, CLAUDE_CODE_MAX_RETRIES raises it to 15 and CLAUDE_CODE_RETRY_WATCHDOG=1 keeps retrying for unattended runs.

Run Claude Code on the gateway

Same models, two environment variables, credits at 7.69× face value — or a flat-rate unlimited plan. New accounts: $5 in free API credit with code FIXIT.

Get an API key See unlimited plans

AI Prime Tech is an independent API gateway and is not affiliated with, endorsed by, or sponsored by Anthropic. “Claude” and “Claude Code” are trademarks of Anthropic. Claude Code features described here follow Anthropic’s public documentation at the time of writing and change frequently; prices and model lists on this page are read from this gateway’s live settings.

More Claude Code guides

Claude Code errors and how to fix themClaude Code "API Error: 500": what it means and what actually fixes itClaude "Overloaded" error (API Error 529): what it means and what to doClaude Code API Error 400: prompt is too long, tool use concurrency, and the restClaude Code OAuth errors: timeout of 15000ms exceeded, and status code 500"Claude Code process exited with code 1": how to find the real error and fix itClaude "Prompt is too long", "input is too long for requested model" and "Context limit reached": what fills the window and how to get it backClaude usage limit reached: session, weekly and Opus limits, "specified API usage limits", "credit balance is too low" — and what to doClaude Code 401 and 403: invalid authentication credentials, invalid API key, "Not logged in", host_not_allowedClaude Code hangs, gets stuck or stops responding: how to find out where it is stuck and get outClaude.ai not working: "Something went wrong", capacity constraints, "5-hour limit reached", "error logging you in" and the rest