Headroom

Fix "Login expired · Please run /login" in Claude Code

What "Login expired · Please run /login" means in Claude Code, the three-day warning before it, how to renew the login, and why long unattended runs stop.

· 6 min read

"Login expired · Please run /login" means Claude Code tried to renew your saved claude.ai login, the renewal was rejected, and Claude Code cleared the saved credentials. Type /login at the Claude Code prompt, finish signing in in the browser, and carry on. Retrying without signing in shows the same message every time. Nothing is wrong with your plan or your usage limits.

What the message means

Anthropic's error reference explains that Claude Code tried to renew your saved login "and the OAuth service rejected the stored refresh token, so Claude Code cleared the saved credentials." After that, each model request stops on your machine with this message before it reaches the API, "because only /login can create new credentials."

The authentication docs describe the run-up. When a login you created with /login is within three days of expiring, Claude Code shows this at startup:

Your login expires in 3 days · run /login to renew

That warning is informational and never blocks a request, and it appears only when a claude.ai login is the active credential. Once the login has expired and cannot be refreshed, each model request fails with:

Login expired · Please run /login

In non-interactive mode (-p) and the Agent SDK, the same state reads:

Failed to authenticate: OAuth session expired and could not be refreshed

In Claude Code v2.1.210 or later, /status also shows a Login row marking the login as expired, with the organization and email it had saved. The row appears only when that saved login is your active credential, so it is a quick way to confirm this is the problem.

This is an authentication message, not a limit message. If instead you see "You've hit your session limit", that is a usage limit; see what to do when you hit the session limit.

The fix

  1. At the Claude Code prompt, run /login.
  2. Claude Code opens a browser. Sign in with the account you used before.
  3. If the browser does not open, press c to copy the login URL. If the browser shows a code instead of returning to the terminal, paste it at the "Paste code here if prompted" prompt.
  4. The terminal shows "Login successful"; press Enter to continue.

Those steps are from the authentication docs. Pick the login type that matches how you pay. Pro, Max and Ultra subscribers log in with the same credentials they use for Claude. Team and Enterprise members choose "Claude account with subscription" and then their organization (Claude Code with a Team or Enterprise plan). If you pick a Console account by mistake, your usage bills to the Console, not your plan; see why Claude Code bills your API key instead of your plan.

Other open windows may not need anything. Parallel sessions on one machine share a saved login, and if you sign in with your claude.ai account in another Claude Code window that uses the same configuration directory, an interactive session showing "Not logged in" starts using that login on its own. On macOS that needs v2.1.286 or later; on older versions, restart the session that still shows the message (error reference).

Anthropic's error reference lists close neighbours, and the fix for each is also /login:

  • "Not logged in · Please run /login" means no valid credential is available for the session.
  • "OAuth token revoked · Please run /login" means "you signed out everywhere or an admin removed access".
  • A message that starts "Please run /login · API Error: 401 OAuth token has expired" means the automatic refresh failed mid-session.

If you have a Team or Enterprise seat and Claude Code says Pro, Max or Ultra is required, Anthropic's Claude Code FAQ says "you selected the wrong login method". Run /login again and pick the account tied to your work email.

If it keeps coming back on a Mac

Anthropic's troubleshooting page points to two things when you are asked to log in often. First, check that your system clock is accurate, "as token validation depends on correct timestamps". Second, on macOS, check where the login is stored. Claude Code saves credentials to the login Keychain; when the Keychain rejects the write, for example when it is locked in an SSH session or its password is out of sync with your account password, Claude Code falls back to the plaintext ~/.claude/.credentials.json file.

To make the Keychain writable again, start with claude doctor. If its report lists a warning that starts "macOS Keychain is not writable", unlock your login keychain and enter its password when asked:

security unlock-keychain ~/Library/Keychains/login.keychain-db

If unlocking does not clear the warning, open Keychain Access, select the login keychain and resync its password with Edit > Change Password for Keychain "login". Once claude doctor shows no Keychain warning, run /logout and then /login to move the login back into the Keychain. Logging out "removes all stored credentials, including the plaintext file's contents, saved MCP server logins, and plugin sensitive values", so expect to re-authorize MCP servers afterwards.

Users have also reported other causes of repeated login prompts on macOS on GitHub, including a zeroed Keychain entry (#93051) and Claude Desktop's embedded Claude Code rotating the CLI's refresh token (#94464). Those are user reports, not documented behaviour, but they are worth a search if the steps above do not hold.

Why unattended sessions stop

Anthropic says renewing early "matters most for sessions that run unattended": a background session or Remote Control session "that outlives the login stops making progress once the credential expires and can't recover until you sign in again" (authentication docs). Users have reported exactly this stopping overnight work (GitHub issue #104806) and asked for an earlier warning (#108372).

The three-day warning appears at startup, so a session you started days ago will not show it. Two habits follow from that:

  • Before leaving long work to run, start a fresh claude with the same configuration folder. If the three-day warning appears, run /login before you go.
  • If a session has stopped, look for "Login expired" in the transcript or an expired Login row in /status, run /login, then ask Claude to pick the task up again.

For automation that cannot sign in interactively, Anthropic points to an API key (which bills a Console account at API rates, not your plan) or a long-lived token. claude setup-token creates a one-year OAuth token and requires a Claude subscription. It "does not save the token anywhere"; you set it as the CLAUDE_CODE_OAUTH_TOKEN environment variable. That token also expires eventually, and you then see the "OAuth token revoked or expired" messages. Treat it like a password, and remember Anthropic's terms say you may not share your account credentials with anyone else (Consumer Terms).

Several accounts

Each CLAUDE_CONFIG_DIR folder has its own login, so one account can expire while the others are fine. Anthropic's docs say to give each account its own configuration directory "to stay signed in to multiple accounts at once, such as work and personal accounts". The /login fix renews only the folder you are in. See how CLAUDE_CONFIG_DIR works.

Seeing a lapsed sign-in without opening Claude Code

Headroom is a free Mac menu bar app that lists every Claude Code account signed in on your Mac. When an account's sign-in has lapsed, its row shows "Sign-in lapsed." with a "Sign In Again…" link that runs the same sign-in for that account. It reads the sign-in Claude Code already saved on your Mac and never sends a prompt. It cannot fix a Keychain problem for you, and it is independent, not made or endorsed by Anthropic. See what the Headroom sign-in lapsed row means, or get the app at headroom.everydaymactools.com.