Fix Claude Code "API Error: 500 Internal server error"
Claude Code API Error 500 Internal server error is a temporary API-side failure. Check the status page, type try again, and test tool search behind a gateway.
API Error: 500 Internal server error. This is a server-side issue, usually temporary — try again in a moment. If it persists, check https://status.claude.com.API Error: 500 in Claude Code means an unexpected failure inside the API, and the official docs state it is not caused by your prompt, settings, or account. Check the status page for an incident and send the message again after about a minute. By the time you see this line, Claude Code has already used its automatic retries (up to 10 by default, with exponential backoff).
[1] Read the last sentence of the message to see where the error came from. It changes with how you connect.
| The sentence points to | Meaning |
|---|---|
https://status.claude.com | Direct connection to the Anthropic API |
| Amazon Bedrock, Google Cloud Agent Platform or Microsoft Foundry status | A 5xx from that cloud provider's service |
| A gateway host name | A 5xx from the gateway set in ANTHROPIC_BASE_URL |
If the status code is followed by a short title, as in API Error: 502 Bad Gateway, a proxy, load balancer or gateway answered with an HTML error page. Check that device's logs, not the API (the title is shown as of v2.1.281).
[2] Check service status. Open status.claude.com in a browser, or read the status page's public JSON from a terminal. No authentication is needed.
$ curl -s https://status.claude.com/api/v2/status.json | jq -r .status.descriptionAll Systems Operational$ curl -s https://status.claude.com/api/v2/components.json | jq -r '.components[] | select(.group|not) | "\(.name): \(.status)"'claude.ai: operationalClaude Console (platform.claude.com): operationalClaude API (api.anthropic.com): operationalClaude Code: operationalClaude Cowork: operationalClaude for Government: operational$ curl -s https://status.claude.com/api/v2/incidents/unresolved.json | jq ".incidents | length"0An open incident may affect only another component, such as claude.ai or Cowork. On the status page, check whether the incident lists Claude API (api.anthropic.com) or Claude Code as affected (on Bedrock, Agent Platform, Foundry, or a gateway, check the status page that the trailing sentence in [1] names instead). If the component on your request path is not operational, or an open incident affects it, the only fix is to wait. Changing settings will not help. If the incident affects only other components, continue with [3].
[3] Wait about a minute and send again. Your original message is still in the conversation, so type try again instead of pasting a long prompt again.
[4] If you use an LLM gateway through ANTHROPIC_BASE_URL and every request fails with 500, test whether the gateway rejects the tool search fields Claude Code sends. Since v2.1.304 tool search is on by default behind a gateway too, so if the failures started right after an update, check this first.
$ ENABLE_TOOL_SEARCH=false claudeIf that works, fix the gateway, or keep the value in the env block of your settings file until then.
[5] If transient 5xx errors break unattended runs such as CI jobs, raise the retry budget. CLAUDE_CODE_RETRY_WATCHDOG=1 raises the default retry count for server errors, timeouts and dropped connections to 300, roughly three hours of backoff. To see failures sooner in an interactive session, lower CLAUDE_CODE_MAX_RETRIES instead.
[6] If it keeps happening with no posted incident, run /feedback inside the session. It sends the transcript and your description to Anthropic and offers to open a prefilled GitHub issue. On Bedrock, Agent Platform, Foundry and other third-party providers, /feedback only saves a local archive, which you send to your Anthropic account representative. For installation details, run claude doctor from your shell.
Related errors with different causes: for Repeated 529 Overloaded errors see Claude Code error messages and fixes, for 429 see usage limit or outage, and for No response from API, where no response headers arrive, see No response from API timeout.