Claude Code Error Handling

Every Claude Code error has a root cause and a fix. This page organizes every documented error by type, links to step-by-step resolution guides, and teaches you a systematic diagnostic approach so you can fix new errors independently.

Bookmark this page. When Claude Code throws an error, start here.


API Errors (HTTP Status Codes)

API errors are the most common category. Each HTTP status code indicates a specific problem with your request, authentication, or the Anthropic service.

400 – Bad Request

The API rejected your request due to malformed input, invalid parameters, or schema violations.

401 – Authentication Error

Your API key is missing, expired, or malformed.

413 – Request Too Large

Your prompt or context exceeds the model’s input token limit.

429 – Rate Limit Exceeded

You have exceeded your API rate limit or token budget.

500 – Internal Server Error

The Anthropic API encountered an internal failure.

529 – Overloaded

The API is temporarily overloaded and cannot process your request.


SDK and Runtime Errors

These errors occur within the Anthropic SDK itself, usually during streaming, tool use, or structured output processing.


JSON Parse Errors

JSON parsing failures occur when Claude Code receives malformed responses or when configuration files contain syntax errors.


Permission and Access Errors

Permission errors block Claude Code from reading, writing, or executing in your project.


MCP Server Errors

MCP (Model Context Protocol) server errors occur during tool integration and external service communication.


Process and System Errors

These errors relate to Claude Code’s runtime process, system resources, or integration with your development environment.


Diagnostic Approach

When you encounter an error not listed above, follow this systematic process:

  1. Read the error message carefully. Claude Code errors include specific codes and descriptions. The error code alone often points to the fix.
  2. Check your configuration. Most errors trace back to CLAUDE.md syntax, settings.json misconfigurations, or environment variable issues.
  3. Isolate the component. Determine whether the error originates from the CLI, the API, an MCP server, or your project code.
  4. Use the diagnostic tool. The Claude Code Diagnostic Tool walks you through error identification and resolution interactively.
  5. Check API status. For 500 and 529 errors, verify the Anthropic API status page before debugging your own configuration.

Frequently Asked Questions

What is the most common Claude Code error?

Error 429 (Rate Limit Exceeded) is the most frequently encountered error, especially for teams running multiple agents in parallel. The fix involves implementing exponential backoff, distributing requests across time windows, and optionally upgrading your API tier.

How do I fix Claude Code permission denied errors?

Permission denied errors have three common causes: npm global install permissions (fix with nvm or npm config), sandbox mode restrictions (check your permission mode setting), and file system permissions in Docker containers (fix bind mount ownership). Start with the Permission Denied Shell Commands guide.

Why does Claude Code crash on large files?

Claude Code loads file contents into the context window. Files exceeding the context limit cause crashes or truncation. Split large files, use .claudeignore to exclude generated files, and set max file size limits in your CLAUDE.md. See Fix Claude Code Large File Crashes.

How do I debug MCP server connection issues?

First, verify the MCP server process is running. Then check transport configuration (stdio vs HTTP). Next, test the connection independently using curl or the MCP inspector. Finally, review timeout settings. The MCP Server Incident Response Guide covers all steps.

What causes JSON parse errors in Claude Code?

Three sources: truncated API responses (network interruption), malformed configuration files (syntax errors in settings.json), and response schema mismatches (SDK version incompatibility). The fix depends on the source. See Fix Unexpected Token in JSON.

How do I handle Claude API 500 errors?

API 500 errors are server-side issues at Anthropic. Implement retry logic with exponential backoff (initial delay 1s, max 3 retries). If errors persist beyond 5 minutes, check the Anthropic status page. Your code is not the problem. See Fix Claude API Error 500.

Can I prevent errors before they happen?

Yes. Add error-prevention rules to your CLAUDE.md (file size limits, forbidden patterns, required validations). Use pre-commit hooks to validate Claude’s output before it commits. Enable the diagnostic tool for real-time error detection. See CLAUDE.md for Error Handling.

Where do I report Claude Code bugs?

Report bugs to the Anthropic Claude Code GitHub repository. Include your Claude Code version, the full error message, your operating system, and minimal reproduction steps. The Bug Reporting Best Practices guide shows how to write effective bug reports.

Try our Diagnostic Tool → Diagnose your Claude Code error instantly

Stop Debugging, Start Building

This error reference covers the documented error types. For proactive error prevention patterns, debugging workflows, and production monitoring configurations, the Claude Code Mastery Playbook ($99) includes 200 production-tested practices that help you avoid errors entirely.