Claude Code 500 Internal Server Error: Is It Your Setup or the API?

What API Error: 500 Internal server error. This is a server-side issue, usually temporary — try again in a moment. means, whether to wait, and what to check first.

Language: English · 日本語版

500 api_error Usually clears if you wait Official documentation checked on

Wait or fix?

Usually wait. The official reference says a 5xx from the API itself indicates an unexpected failure inside the API and is not caused by your prompt, settings or account. Waiting a minute and sending again is the main fix. Your setup matters in two cases only: when a proxy or gateway sits between you and the API and answers with its own error page (the message then shows something like 502 Bad Gateway), and when every single request fails through an LLM gateway set in ANTHROPIC_BASE_URL.

Messages you may see

  • API Error: 500 Internal server error. This is a server-side issue, usually temporary — try again in a moment.
  • API Error: 502 Bad Gateway
  • 500 api_error

The exact wording changes a little between Claude Code versions and providers.

What the message means

Claude Code shows the status code and the API's error message for any 5xx response. The Claude API documentation describes 500 api_error as an unexpected error inside Anthropic's systems, to be retried with exponential backoff, and suggests contacting support with the request ID if it persists. Claude Code already retries server errors that arrive before any of the response has streamed, up to 10 times with backoff. When the failure arrives after Claude has completed a block of text or a tool call, Claude Code keeps what was completed instead of running the request again, because running it again could repeat the same tool calls.

Common causes

  • An unexpected failure inside the API. This covers most cases.
  • A proxy, load balancer or gateway that answered with an HTML error page. Claude Code shows its status code and the page's title.
  • With ANTHROPIC_BASE_URL pointing at an LLM gateway, a gateway or upstream that does not accept the tool search fields Claude Code sends by default.

Check in this order

  1. Check status.claude.com, or the provider status page named at the end of the message, for active incidents.
  2. Wait a minute, then send your message again. Your original message is still in the conversation, so for a long prompt you can type "try again" instead of pasting it.
  3. If the code is 502 or another status followed by a page title, look at the proxy or gateway between you and the API rather than at Claude Code.
  4. If ANTHROPIC_BASE_URL points at a gateway and every request fails this way, check that the gateway and its upstream accept tool search fields (defer_loading and tool_reference, sent with the anthropic-beta header).
  5. If the error persists and no incident is posted, run /feedback so Anthropic can investigate with your request details.

We took the fixes from the official pages below and put them in order, with the quickest and most likely ones first.

How it differs from similar errors

  • 529 Overloaded is also on the server side, but it means capacity, and switching models can help.
  • "Request timed out" and "Unable to connect to API" mean the connection itself failed, which usually points at your network or proxy.
  • 429 errors are limits rather than failures, and /status is the first check for them.

Related errors

Official sources

Unofficial page. Not affiliated with, endorsed by, or sponsored by Anthropic, PBC. Claude and Claude Code are trademarks of Anthropic, PBC. Messages and fixes change with updates, so read the official pages as well.

Back to the error list (10 errors)