Claude Code API Error 401 Please Run Login
When Claude Code shows Please run /login · API Error: 401, unset a conflicting API key, logout, update, fully restart the terminal, then login again.
Quick answer
Match Please run /login · API Error: 401, including Invalid authentication credentials, Invalid bearer token, or OAuth token has expired. Run /status, unset ANTHROPIC_API_KEY if an API key is overriding OAuth, run /logout even if it also 401s, update Claude Code, fully quit and reopen the terminal, then /login for a fresh OAuth session. On Windows, clear leftover Claude or Anthropic entries in Credential Manager if logout did not stick. Never paste tokens into chat. This is not the Login successful then Not logged in loop without 401.
On this page
What we're seeing
- The exact matchable clause is Please run /login · API Error: 401, often with Invalid authentication credentials, Invalid bearer token, or OAuth token has expired.
- Independent January–July 2026 first-hand anthropics/claude-code issues quote that 401 login screen across desktop and Remote Control sessions.
- First-hand leftovers start with clearing an overriding ANTHROPIC_API_KEY, then logout, update, full terminal restart, and a fresh /login.
- A different fingerprint is Login successful followed by Not logged in · Please run /login without API Error: 401. That path uses keychain and setup-token leftovers instead.
- Weekly-limit and overloaded waits are out of scope.
Start here
Try these first
Fix 1
Confirm Please run /login · API Error: 401
Match the 401 clause before changing credentials. The non-401 Not logged in loop is a different guide.
- Read the error. This guide is for Please run /login · API Error: 401, including Invalid authentication credentials, Invalid bearer token, or OAuth token has expired.
- If you only see Login successful then Not logged in · Please run /login with no API Error: 401, stop here and use that separate guide.
- Run /status and note whether an API key env conflict or expired OAuth session is shown.
Applies to Windows, Mac, Desktop
Fix 2
Unset ANTHROPIC_API_KEY if it overrides OAuth
First-hand Support and community leftovers for this 401 screen clear when a shell API key stops overriding the OAuth login path.
- In the same terminal that launches Claude Code, check whether ANTHROPIC_API_KEY is set.
- If it is set and you intend to use OAuth login, unset ANTHROPIC_API_KEY for that session or remove it from your shell profile.
- Do not paste API keys or OAuth tokens into chat, tickets, or screenshots.
Applies to Windows, Mac, Desktop
Fix 3
Logout, update, restart, then login
March–July 2026 first-hand threads with the exact 401 screen clear after /logout, claude update, a full terminal restart, and a fresh /login even when logout itself returns 401.
- Run /logout. Continue even if logout also shows API Error: 401.
- Run claude update and wait for it to finish.
- Fully quit the terminal or Claude Code app, then open a new session.
- Run /login and complete the browser OAuth flow on your machine.
- Confirm a normal prompt returns without Please run /login · API Error: 401.
Applies to Windows, Mac, Desktop
Fix 4
Clear Windows Credential Manager leftovers
Windows first-hand reports for this screen clear after removing stale Claude or Anthropic credential entries when logout did not stick.
- Open Credential Manager or run cmdkey /list and find Claude or Anthropic entries.
- Delete only those Claude or Anthropic entries, then restart the terminal.
- Run /login again for a fresh OAuth session.
Applies to Windows, Desktop
Fix 5
Remote Control: ESC then retry
A July 2026 first-hand Remote Control report with the exact 401 screen cleared after ESC and retrying the request when in-place /login could not finish on the loopback path.
- If you are in Remote Control and /login is stuck after API Error: 401, press ESC.
- Retry the same request or restart the remote session, then /login again from a normal local terminal if needed.
Applies to Windows, Mac, Desktop
Device notes
- Windows
- Credential Manager leftovers and ANTHROPIC_API_KEY overrides are common for this 401 screen. Prefer logout and credential clear before recreating profiles.
- Mac
- Same logout → update → full restart → /login leftover. Unset ANTHROPIC_API_KEY when it overrides OAuth.
- Desktop
- Require the API Error: 401 clause. Without it, use the separate Not logged in after Login successful guide.
Official information
Checked on 10 September 2026, anthropics/claude-code GitHub issues that quote Please run /login · API Error: 401 document first-hand leftovers for unsetting ANTHROPIC_API_KEY, /logout, claude update, full terminal restart, fresh /login, Windows Credential Manager cleanup, and Remote Control ESC+retry. Official Claude Code auth docs describe login and logout but do not publish a dedicated page that names only this exact 401 screen.
Sources
Keep troubleshooting
Related problems
Claude
Claude Code Not Logged In Please Run Login
Windows · Mac · DesktopUpdated Sep 9, 2026
Claude
Claude Code MCP Error -32000 Connection Closed
Windows · Mac · DesktopUpdated Sep 7, 2026
Claude
Claude Code PreToolUse Bash Hook Error
Windows · Mac · DesktopUpdated Sep 7, 2026
Claude
Claude Code Credit Balance Too Low
Windows · Mac · DesktopUpdated Sep 12, 2026