[BUG] Authentication issue
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Bug Report — Claude Code 401 Authentication Error
Summary
Every command inside Claude Code returns a 401 authentication error, including/logout, despite the welcome screen correctly identifying the user and showing
a valid Claude Max subscription.
Environment
- Claude Code version: 2.1.87
- OS: macOS (Apple Silicon — MacBook Pro)
- Shell: zsh
- Node: (via Homebrew)
- Authentication method: claude.ai account ([mike@goalatlas.com](mailto:mike@goalatlas.com))
- Subscription: Claude Max
Steps to reproduce
- Run
claudein terminal - Welcome screen displays correctly: "Welcome back Mike!", Claude Max,
correct email, correct organisation
- Type any command — e.g.
hello,run <file>,/logout - Every command returns:
Please run /login · API Error: 401
{"type":"error","error":{"type":"authentication_error",
"message":"Invalid authentication credentials"},
"request_id":"req_..."}
What was tried
The following steps were attempted without resolving the issue:
claude /logout— returns 401, cannot complete logoutrm -rf ~/.claude— deleted stored credentials entirely- Re-ran
claude— welcome screen appeared again correctly, but all
commands still 401
unset ANTHROPIC_API_KEY— confirmed no API key in environmentnpm update -g @anthropic-ai/claude-code— updated to 2.1.87- Fresh terminal window — same result
echo $ANTHROPIC_API_KEY— prints nothing (no key set)
Additional context
During troubleshooting, an ANTHROPIC_API_KEY was temporarily added to~/.zshrc, which created an auth conflict warning. This was subsequently
removed and unset in the current session. The conflict warning no longer
appears, but the 401 persists.
The welcome screen data (name, subscription, email, organisation) is correct
at every attempt, suggesting the stored token is being read but rejected
when used for API calls.
Expected behaviour
Commands should execute normally once the welcome screen confirms a valid
authenticated session.
Actual behaviour
Every command, including /logout, returns 401 Invalid authentication
credentials regardless of what is typed.
What Should Happen?
Commands should execute normally once the welcome screen confirms a valid
authenticated session.
Error Messages/Logs
Every command, including `/logout`, returns 401 Invalid authentication
credentials regardless of what is typed.
Steps to Reproduce
- Run
claudein terminal - Welcome screen displays correctly: "Welcome back Mike!", Claude Max,
correct email, correct organisation
- Type any command — e.g.
hello,run <file>,/logout - Every command returns:
Please run /login · API Error: 401
{"type":"error","error":{"type":"authentication_error",
"message":"Invalid authentication credentials"},
"request_id":"req_..."}
### Claude Model
Sonnet (default)
### Is this a regression?
I don't know
### Last Working Version
_No response_
### Claude Code Version
Don't know - cannot run Claude Code
### Platform
Anthropic API
### Operating System
macOS
### Terminal/Shell
Terminal.app (macOS)
### Additional Information
_No response_This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗