Claude Code API Error 401 and Login Loop

Share
Workaround available Claude Code (CLI) Updated November 14, 2026Based on 3 user reportsHow we research

Quick answer

Usually an environment variable overriding /login or an expired token: run /status, then /logout, update and /login again.

Most likely fix: Run /status

How to fix it

Try these in order — the most common fix is first.

  1. 1. Run /status

    1. Check which credential is in use before deleting anything
    Did this fix it?
  2. 2. Remove overriding variables

    1. Unset ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN or CLAUDE_CODE_OAUTH_TOKEN if stale
    Did this fix it?
  3. 3. Log out, update, log in

    1. Run /logout
    2. Run claude update
    3. Run /login
    Did this fix it?
  4. 4. Check the clock

    1. Sync your system time
    Did this fix it?

Symptoms

'API Error: 401' or OAuth token expired; /login loops.

Why it happens

  • ANTHROPIC_API_KEY or other env variables override /login
  • Expired or revoked token
  • Outdated Claude Code
  • Wrong system clock

This guide also covers

  • claude code 401
  • claude code oauth token expired

Still not working?

If Anthropic Claude keeps failing, you're not alone. See every Anthropic Claude problem users report or the alternatives people switch to.

Have an app idea? Our small team builds any software: web and mobile apps, games, desktop, AI tools. Price agreed together.

Talk to us
Fixed it? Share this guide

The same problem in other apps

All login, account & activation guides →

Other Anthropic Claude errors

All 11 Anthropic Claude errors and fixes →