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

Claude Code errors and how to fix them

Claude Code surfaces API errors with the HTTP status in the message, so the number tells you most of the story. Here is what each one means in the context of an agent session, and the fix that actually works.

TLDR

  • 500 / 529 — the model side is failing or saturated; retry with backoff, switch model, nothing to fix in your setup.
  • 400 — usually context too long for the model; /compact or /clear, or move to a 1M-context variant.
  • 429 — rate limit; Claude Code's parallel streams hit concurrency first.
  • 401 — wrong key for the endpoint; a console key against a gateway URL or vice versa.
  • Usage limit / weekly limit — a subscription window, not an API error; it resets on its own, and the API route has no such window.

Detailed guides for each error

API error 500 (and 529 overloaded)

A 500 is an upstream failure; 529 is Anthropic's explicit "model at capacity" code. Neither is caused by your prompt. Claude Code retries a few times on its own; if it gives up, wait a minute and resume with claude -c. Switching tier with /model often works immediately because capacity is per model. On this gateway a saturated upstream account is failed over automatically, which is why 529s are rarer here than against a single account.

API error 400 — bad request / context too long

In Claude Code a 400 almost always means the conversation plus the files it has read no longer fit the model's window. /compact summarises history; /clear starts fresh; or switch to a (1M) variant of the model. Other 400s: an unsupported parameter after an upgrade (run claude update), or an image or file the model cannot accept.

API error 429 — rate limit / rate exceeded

Three limits apply: requests per minute, tokens per minute and concurrent requests. Agentic sessions hit concurrency first — every subagent is a parallel streaming request holding a slot until it finishes. Reduce parallelism, let the retry-after elapse, and for sustained work ask for a higher concurrency on your gateway account.

OAuth error: timeout of 15000ms exceeded

The /login flow could not reach Anthropic's auth service within 15 seconds. It is a network problem, not an account one: a corporate proxy, a VPN that drops the callback, or a region where the auth endpoint is slow. Retry once; if it persists, set HTTPS_PROXY for your network, or skip OAuth entirely by using an API key — with ANTHROPIC_API_KEY (and ANTHROPIC_BASE_URL for a gateway) Claude Code never opens the login flow at all.

OAuth error: request failed with status code 500

The auth service answered with a server error during login or token refresh. Nothing on your side causes it; wait a few minutes and run /login again. If you need to work now, the API-key route above bypasses OAuth, and claude setup-token on a machine where login works produces a long-lived token you can move to the one where it does not.

Error: Claude Code process exited with code 1

This is the IDE extension or desktop app reporting that the CLI it launched crashed at startup — the real error is one level down. Open a terminal and run claude directly: you will see the actual message, which is almost always a Node.js version below 18, a broken PATH after an npm install, a corrupt native install, or a settings.json with invalid JSON (a stray comma in a hooks block is a classic). claude doctor checks the first three; a JSON linter catches the fourth. Reinstalling with the native installer fixes most of the rest.

401 / authentication errors

invalid x-api-key or authentication_error means the key does not belong to the endpoint. If ANTHROPIC_BASE_URL points at the gateway, the key must be a gateway key; an Anthropic console key will be refused, and the reverse is also true. /status shows which endpoint and key are active. If you use /login and an API key at the same time, the key wins. Token-refresh loops, Not logged in after a successful login and 403s from proxies are on the 401 / 403 page.

"No healthy upstream"

Not an API error: it is the load balancer in front of a service reporting that no backend is available. On the official endpoint it means an outage; from a gateway it means the whole upstream pool is down or throttled. Wait and retry; do not change your configuration.

Claude Code not working at all

  • Starts then exits silently → run claude /doctor; usually a Node version or PATH problem.
  • Hangs at startup or mid-session → see hangs and stuck sessions and connection errors.
  • command not found → see the install guide.
  • Tools fail with permission errors → /permissions, or --allowedTools in scripts.

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

Why does Claude Code keep returning API error 500?

The model backend is failing or overloaded (529 is the explicit form). Retry after a pause, switch tier with /model, or resume with claude -c. It is not your configuration.

How do I fix Claude Code error 400 context length?

Run /compact to summarise the session, /clear to reset, or switch to a 1M-context model variant.

Why does Claude Code say invalid API key?

The key does not match the endpoint in ANTHROPIC_BASE_URL. Gateway URL needs a gateway key; Anthropic URL needs a console key.

Run Claude Code on the gateway

Same models, two environment variables, credits at 7.69231× 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: the complete guideHow to install Claude CodeClaude Code CLI documentation: commands and flagsClaude Code pricing and limits, explainedThe Claude Code SDK, now the Claude Agent SDKClaude Code skills and pluginsClaude Code in GitHub: the App, the Action and @claudeDoes Claude Code have a web interface? Web, desktop and IDE explainedWhich model Claude Code uses, and how to change itIs Claude Code open source?Claude Code tutorial: your first real sessionClaude for students: Claude Code, the API and what education actually gets youHow to use Claude Code for QA automationClaude Code vs Cursor: which one, when — and how to run bothClaude Code vs Codex vs OpenCode: the terminal agents comparedClaude Code subagents: how they work, how to define them, and agent teamsClaude Code hooks: deterministic control over what the agent doesClaude Code MCP: connecting servers, scopes, remote MCP and real examplesThe Claude Code ecosystem: routers, frameworks, plugins and the lists that track themClaude Code in VS Code: the extension, the terminal route, and the errorsHow to use OpenRouter in Claude Code (and when not to)Claude rate limit error: what "API error: rate limit reached" means and how to fix itClaude Code 怎么用:从安装到日常使用