TechFixSignal
Claude

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.

Last checked
Sep 10, 2026
Applies to
Windows, Mac, Desktop
Fix status
Community Confirmed
Fastest useful check

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

Community Confirmed

Match the 401 clause before changing credentials. The non-401 Not logged in loop is a different guide.

  1. 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.
  2. 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.
  3. 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

Community Confirmed

First-hand Support and community leftovers for this 401 screen clear when a shell API key stops overriding the OAuth login path.

  1. In the same terminal that launches Claude Code, check whether ANTHROPIC_API_KEY is set.
  2. 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.
  3. 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

Community Confirmed

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.

  1. Run /logout. Continue even if logout also shows API Error: 401.
  2. Run claude update and wait for it to finish.
  3. Fully quit the terminal or Claude Code app, then open a new session.
  4. Run /login and complete the browser OAuth flow on your machine.
  5. Confirm a normal prompt returns without Please run /login · API Error: 401.

Applies to Windows, Mac, Desktop

Fix 4

Clear Windows Credential Manager leftovers

Community Confirmed

Windows first-hand reports for this screen clear after removing stale Claude or Anthropic credential entries when logout did not stick.

  1. Open Credential Manager or run cmdkey /list and find Claude or Anthropic entries.
  2. Delete only those Claude or Anthropic entries, then restart the terminal.
  3. Run /login again for a fresh OAuth session.

Applies to Windows, Desktop

Fix 5

Remote Control: ESC then retry

Community Confirmed

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.

  1. If you are in Remote Control and /login is stuck after API Error: 401, press ESC.
  2. 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