Claude Code login / authentication fails (Invalid API key / Please run /login / OAuth): causes and fixes
Is there an outage right now?
Claude Code official status is operational. If this error persists, it is likely an implementation or environment issue on your side.
Updated: Jun 6, 2026, 4:55 AM UTC
View Claude Code status →What this error means
Claude Code fails to sign in or authenticate. Common causes are an OAuth login callback timing out, a locked macOS keychain that cannot store the token, a mismatch between your API key and base URL, or DNS/network issues. "Invalid API key · Please run /login" indicates a bad key or an expired token.
Common causes
- •OAuth login callback timed out
- •macOS keychain is locked and cannot store the auth token
- •API key (sk-ant-…) and base URL (official vs proxy) do not match
- •Tried OAuth in a no-browser environment (SSH/CI/Docker)
- •DNS/proxy/firewall blocks the auth server
- •Outdated version or corrupted cache
How to fix
- 1.Run /logout to fully clear the old token, then /login again
- 2.Update Claude Code, delete ~/.claude/cache, and retry
- 3.In no-browser environments (SSH/CI/Docker), set the ANTHROPIC_API_KEY env var instead of OAuth
- 4.Make sure your API key and base URL come from the same platform (official key → official base URL)
- 5.Run /doctor to check settings, auth, and update problems at once
- 6.On macOS, unlock the keychain; verify network/proxy settings
When waiting helps (and when it won't)
This is an auth/config problem and will not fix itself by waiting. Re-do /logout then /login, update and clear the cache, or set ANTHROPIC_API_KEY in no-browser environments. Running /doctor first is the fastest way to isolate the cause.
Alternatives when Claude Code is down
Related errors
FAQ
What is Login / authentication failed?
Claude Code fails to sign in or authenticate. Common causes are an OAuth login callback timing out, a locked macOS keychain that cannot store the token, a mismatch between your API key and base URL, or DNS/network issues. "Invalid API key · Please run /login" indicates a bad key or an expired token.
How do I fix Login / authentication failed?
Run /logout to fully clear the old token, then /login again / Update Claude Code, delete ~/.claude/cache, and retry / In no-browser environments (SSH/CI/Docker), set the ANTHROPIC_API_KEY env var instead of OAuth / Make sure your API key and base URL come from the same platform (official key → official base URL) / Run /doctor to check settings, auth, and update problems at once / On macOS, unlock the keychain; verify network/proxy settings