Claude Code Error Code 401
The API key or login credential is missing or invalid.
The API key or login credential is missing or invalid.
| Code | 401 |
| Product | Claude Code |
| Company / origin | Anthropic · United States |
| Category | AI & Developer Tools |
| Platform / versions | Claude Code CLI and API · Current Claude Code release |
| Severity | error |
| Official source | Claude Code error reference ↗ |
| Last verified | 2026-11-17 |
What does Claude Code error 401 mean?
Claude Code error 401 means Anthropic rejected the authentication credentials. The API key may be missing, revoked, mistyped, or loaded from a different environment than the terminal session expects.
Common causes
- ANTHROPIC_API_KEY is missing, empty or contains a stale key.
- The key was revoked, rotated or belongs to another workspace.
- A shell profile, CI secret or container is injecting a different value.
How to fix it
- Step 1
Confirm which environment variable or login method Claude Code is using.
- Step 2
Replace the key with a current value and start a new terminal session.
- Step 3
Check the Anthropic Console for revoked keys or workspace restrictions.
When to escalate
Related codes
| Code | Name | What it means |
|---|---|---|
429 | Rate Limit Exceeded | The account or API key exceeded its rate limit. |
529 | API Overloaded | The Anthropic API is temporarily overloaded. |
Source & verification
This page was checked against Claude Code error reference on 2026-11-17. The code, product, and platform fields are kept separate from the explanation so corrections can be made without changing the URL.
Open Error Codes is independent and not affiliated with Anthropic. Always confirm destructive or security-sensitive steps with the official documentation.