TL;DR

A Claude Code login loop can have a local cause the docs name: an approved ANTHROPIC_API_KEY outranking your login, an expired or revoked login, a wrong clock, a full disk, or a login flow that cannot finish over SSH or WSL. Run /status, check status.claude.com for an authentication incident, then use /logout and /login. Back up before deleting any credentials file.

If Claude Code keeps asking you to log in, or /login succeeds and the next request still returns 401, check the causes the Claude Code docs describe, in this order: an environment API key that outranks your login, an expired or revoked login, a wrong system clock, a full disk, and a login flow that never completes in SSH or WSL. Check status.claude.com first, because login can fail on Anthropic's side too. Checked against the official Claude Code docs on 14 November 2026. The steps below are taken from those docs, not run against a real account.

Nothing here asks you to paste a token anywhere. For live incidents, see the Claude Code status hub.

How to tell an outage from a local problem

Open the status page and look for an incident on authentication or login. It has happened: the 13 November 2026 incident began with an investigation into users authenticating to Claude.ai and Claude Code, and was marked resolved at 11:58 UTC the same day. If one is open, wait. The authentication service error guide explains why a reset does not help during an incident.

If nothing is open, work through the table below.

Which login error do you have?

SymptomLikely causeWhat to do
Please run /login · API Error: 401 Invalid authentication credentialsAn approved ANTHROPIC_API_KEY is the active credential, or the login was revokedRun /status, then unset the key or run /login once
Login expired · Please run /loginSaved login expired and could not refreshRun /login; retrying alone repeats the message
OAuth token revoked or OAuth token has expiredSigned out everywhere, admin removed access, or refresh failedRun /login; for automation use a key or claude setup-token
OAuth error: Invalid codeLogin code expired or was truncated when copiedRetry quickly, or press c to copy the full URL
Browser opens on the wrong machine or errors on localhostSSH, WSL2 or containerOpen the printed URL locally and paste the code, or run claude auth login
Login successful but 401 continuesFull filesystem or disk quota, so the login could not be savedFree space, then sign in again
API Error: 403 Request not allowedInactive subscription, missing Console role, or proxyCheck the subscription or role, see the 403 section of the docs

What should you check before logging in again?

Run /status inside Claude Code. The error reference says that if it shows an API key row that is not marked as not in use, an approved ANTHROPIC_API_KEY is the active credential and takes precedence over your login, so /login does not replace it. That is why a fresh login can change nothing, and the precedence list shows where each credential ranks.

If the key is stale, the docs give two options: rotate it in the Claude Console, or fall back to your subscription with unset ANTHROPIC_API_KEY (PowerShell: Remove-Item Env:ANTHROPIC_API_KEY). Only unset a key you can recreate. If ANTHROPIC_BASE_URL points at a gateway, the text after 401 is your gateway's message, and /login does not change it.

What is the safe way to reset a login?

The install and login troubleshooting page gives this sequence:

  1. Run /logout to sign out completely.
  2. Close Claude Code.
  3. Start claude again and complete login.

One caution from the docs: logging out removes all stored credentials, including saved MCP server logins and plugin sensitive values, so expect to re-authorize MCP servers and re-enter plugin secrets afterwards. Make sure you have the plugin secrets to hand before you start.

If the browser does not open, press c to copy the login URL and paste it into a browser yourself. If the browser shows a code instead of returning to the terminal, paste it at the Paste code here prompt. If pasting does nothing, claude auth login reads the code from standard input.

Could the clock, the disk or the Keychain be the cause?

Yes, and the docs name each one. The docs say token validation depends on correct timestamps, so check your system clock if you are prompted to log in often. For a network home directory, the docs say a full filesystem or quota can stop a new login being saved while claude auth login still prints Login successful.: free space, then sign in again.

On macOS, a locked or out-of-sync Keychain makes Claude Code fall back to a plaintext ~/.claude/.credentials.json. Run claude doctor; a warning starting macOS Keychain is not writable confirms it. The docs then give security unlock-keychain ~/Library/Keychains/login.keychain-db, a Keychain password resync if that fails, and a final /logout then /login.

What if /login succeeds and the 401 stays?

Anthropic's docs do not describe this pattern as a fix target; it appears in user reports. In issue 65761, a Linux WSL2 user on Claude Code 2.1.165 reported 401 on every request after about two months of refresh-only use, with /login printing success. The reporter's fix was deleting the saved credentials file and logging in again. The issue was closed as not planned, as a duplicate of issue 61912, which was closed as not planned by a stale-issue bot with no maintainer reply. Its own thread did not establish a cause: the author's later captures contradicted the first theory, and one commenter described a full disk blocking the save, which matches the documented case above.

Treat that as a last resort, and move the file instead of deleting it. On Linux, and on macOS only when it has fallen back to the file, this keeps a copy:

mv ~/.claude/.credentials.json ~/.claude/.credentials.json.bak
claude

Then run /login. The backup still holds a live token, so keep it on your machine, never paste or upload it, and delete it once you are working again. On Windows the file is under %USERPROFILE%\.claude\. The docs do not list this as a fix, so use the documented steps above first. If your configuration directory is set with CLAUDE_CONFIG_DIR, the file lives there instead.

How do you avoid this in CI?

The docs say automation that cannot sign in interactively should authenticate with ANTHROPIC_API_KEY, or with a long-lived token from claude setup-token. That command prints the token and does not save it. Set it as CLAUDE_CODE_OAUTH_TOKEN in your secrets store, never in a repository. The long-lived token needs a Pro, Max, Ultra, Team or Enterprise plan. From Claude Code v2.1.210, /status shows a Login row that reads as expired before a request fails, but only when a saved claude.ai login is the active credential, so you can renew early with /login.

More practical writing for people building with AI tools is on the Lead Source blog.

Fixed? Two optional things

Check Anthropic’s status and get an alert when an incident is resolved: Claude Code status and alerts, an independent resource by Lead Source.

Official source: status.claude.com.

Written by the team at Lead Source, where the day job is lead source tracking: working out which marketing actually brings customers.