Claude Code · Authentication Failed

Claude Code Error Code 401

The API key or login credential is missing or invalid.

errorLast verified 2026-11-17Claude Code error reference
Quick answer

The API key or login credential is missing or invalid.

Code401
ProductClaude Code
Company / originAnthropic · United States
CategoryAI & Developer Tools
Platform / versionsClaude Code CLI and API · Current Claude Code release
Severityerror
Official sourceClaude Code error reference ↗
Last verified2026-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

  1. Step 1

    Confirm which environment variable or login method Claude Code is using.

  2. Step 2

    Replace the key with a current value and start a new terminal session.

  3. Step 3

    Check the Anthropic Console for revoked keys or workspace restrictions.

When to escalate

Before you escalate: If the same Claude Code error persists after checking the API key, account status and Anthropic status page, record the exact error, command, timestamp, region and any request ID, then contact Anthropic support or your API administrator.

Related codes

CodeNameWhat it means
429Rate Limit ExceededThe account or API key exceeded its rate limit.
529API OverloadedThe 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.