claude-code - 💡(How to fix) Fix [BUG] 401 on all API calls despite valid Max subscription — /status confirms auth but every command fails

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

Claude Code authenticates successfully (Welcome screen shows, /status confirms "Login method: Claude Max account") but every API call returns "API Error: 401 Invalid authentication credentials" — including normal prompts, cd, login, and logout commands. Claude Code authenticates successfully (Welcome screen shows, /status confirms "Login method: Claude Max account") but every API call returns "API Error: 401 Invalid authentication credentials" — including normal prompts, cd, login, and logout commands.

Error Messages/Logs

  1. Type any prompt — returns "API Error: 401 Invalid authentication credentials"

Fix Action

Fix / Workaround

Issue has persisted for 24+ hours across:

  1. Multiple fresh installs (npm uninstall + install)
  2. Downgrade to v2.1.89
  3. rm -rf ~/.claude (multiple times)
  4. rm -rf ~/.claude/auth
  5. macOS Keychain clearing (security delete-generic-password)
  6. unset ANTHROPIC_API_KEY (no key was set — env | grep ANTHROPIC returns empty)
  7. --bare mode (returns "Not logged in")
  8. Terminal restarts, full machine restart
  9. claude update (updated model from Sonnet 4.6 to Opus 4.7, still 401s)

Issue has persisted for 24+ hours across:

  1. Multiple fresh installs (npm uninstall + install)
  2. Downgrade to v2.1.89
  3. rm -rf ~/.claude (multiple times)
  4. rm -rf ~/.claude/auth
  5. macOS Keychain clearing (security delete-generic-password)
  6. unset ANTHROPIC_API_KEY (no key was set — env | grep ANTHROPIC returns empty)
  7. --bare mode (returns "Not logged in")
  8. Terminal restarts, full machine restart
  9. claude update (updated model from Sonnet 4.6 to Opus 4.7, still 401s)
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Claude Code authenticates successfully (Welcome screen shows, /status confirms "Login method: Claude Max account") but every API call returns "API Error: 401 Invalid authentication credentials" — including normal prompts, cd, login, and logout commands.

/status output:

The OAuth token exists locally and is linked to the correct Max subscription, but the API rejects it on every call.

Issue has persisted for 24+ hours across:

  1. Multiple fresh installs (npm uninstall + install)
  2. Downgrade to v2.1.89
  3. rm -rf ~/.claude (multiple times)
  4. rm -rf ~/.claude/auth
  5. macOS Keychain clearing (security delete-generic-password)
  6. unset ANTHROPIC_API_KEY (no key was set — env | grep ANTHROPIC returns empty)
  7. --bare mode (returns "Not logged in")
  8. Terminal restarts, full machine restart
  9. claude update (updated model from Sonnet 4.6 to Opus 4.7, still 401s)

Anthropic support bot confirmed this is server-side token validation, not local config.

Environment: macOS, MacBook Pro, Node current stable, Claude Code v2.1.146

What Should Happen?

Claude Code authenticates successfully (Welcome screen shows, /status confirms "Login method: Claude Max account") but every API call returns "API Error: 401 Invalid authentication credentials" — including normal prompts, cd, login, and logout commands.

/status output:

The OAuth token exists locally and is linked to the correct Max subscription, but the API rejects it on every call.

Issue has persisted for 24+ hours across:

  1. Multiple fresh installs (npm uninstall + install)
  2. Downgrade to v2.1.89
  3. rm -rf ~/.claude (multiple times)
  4. rm -rf ~/.claude/auth
  5. macOS Keychain clearing (security delete-generic-password)
  6. unset ANTHROPIC_API_KEY (no key was set — env | grep ANTHROPIC returns empty)
  7. --bare mode (returns "Not logged in")
  8. Terminal restarts, full machine restart
  9. claude update (updated model from Sonnet 4.6 to Opus 4.7, still 401s)

Anthropic support bot confirmed this is server-side token validation, not local config.

Environment: macOS, MacBook Pro, Node current stable, Claude Code v2.1.146

Error Messages/Logs

Steps to Reproduce

  1. npm install -g @anthropic-ai/claude-code
  2. rm -rf ~/.claude
  3. security delete-generic-password -s "claude-code" 2>/dev/null
  4. claude login
  5. Trust the workspace when prompted
  6. Type any prompt — returns "API Error: 401 Invalid authentication credentials"
  7. /status shows Login method: Claude Max account, correct email and org
  8. Every subsequent command also returns 401

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

n/a

Claude Code Version

2.1.146

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] 401 on all API calls despite valid Max subscription — /status confirms auth but every command fails