Claude Code · Sign-in
Not logged in · Please run /login
Claude Code has no valid credential for this session: no saved login and no API key it can use.
Message
The exact error
Not logged in · Please run /loginAlso appears as:
- In the Claude Desktop app (Code tab or Cowork)
- Authentication required · Sign in again to continue
Meaning
What it means
Every request needs either your Claude login or an API key. This message means Claude Code found neither, for example on first run, after logging out, or when you expected an ANTHROPIC_API_KEY that isn’t actually exported in this shell.
Causes
Common causes
- You haven’t signed in yet, or you logged out
- An
ANTHROPIC_API_KEYset in a different shell or profile than the one you launchedclaudefrom - Repeated prompts: a wrong system clock, or on macOS a Keychain that can’t be written
Fix
How to fix it
Sign in
Run
/loginand sign in with your Claude subscription or Console account.If you meant to use an API key, check it’s exported
These print only the first characters, so the key doesn’t end up on screen or in your history.
macOS / Linux echo "${ANTHROPIC_API_KEY:0:7}" # should print sk-ant-Windows PowerShell $env:ANTHROPIC_API_KEY.Substring(0, 7) # should print sk-ant-If it keeps asking you to log in
Make sure your system clock is set automatically, since login tokens depend on correct time. On macOS, run
claude doctor; amacOS Keychain is not writablewarning means you should unlock the login keychain (security unlock-keychain ~/Library/Keychains/login.keychain-db), then/logoutand/login.For CI and automation
Where you can’t log in interactively, use an API key, a long-lived token from
claude setup-token, or anapiKeyHelperscript.
Related