[BUG] API Error: 401 Invalid authentication credentials

Open 💬 22 comments Opened Jun 20, 2026 by LAI0220

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

OS: Windows

Error Message:
API Error: 401 Invalid authentication credentials

Subscription Status:
Pro (expires on June 30)

Troubleshooting Steps Already Attempted:

  • Ran claude logout
  • Ran claude login
  • Deleted %APPDATA%\Claude
  • Reinstalled Claude completely

None of the above steps resolved the issue.

What Should Happen?

claude login

●Please run /login · API Error: 401 Invalid authentication credentials

✻ Worked for 2s

Remove-Item -Recurse -Force "$env:APPDATA\Claude"

●Please run /login · API Error: 401 Invalid authentication credentials

✻ Churned for 2s

claude login

●Please run /login · API Error: 401 Invalid authentication credentials

✻ Sautéed for 2s

claude /login

●Please run /login · API Error: 401 Invalid authentication credentials

✻ Cogitated for 2s

接著作

●Please run /login · API Error: 401 Invalid authentication credentials

✻ Crunched for 2s

Error Messages/Logs

Steps to Reproduce

OS: Windows

Error Message:
API Error: 401 Invalid authentication credentials

Subscription Status:
Pro (expires on June 30)

Troubleshooting Steps Already Attempted:

  • Ran claude logout
  • Ran claude login
  • Deleted %APPDATA%\Claude
  • Reinstalled Claude completely

None of the above steps resolved the issue.

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

Claude Code v2.1.183

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

PowerShell

Additional Information

OS: Windows

Error Message:
API Error: 401 Invalid authentication credentials

Subscription Status:
Pro (expires on June 30)

Troubleshooting Steps Already Attempted:

  • Ran claude logout
  • Ran claude login
  • Deleted %APPDATA%\Claude
  • Reinstalled Claude completely

None of the above steps resolved the issue.

View original on GitHub ↗

22 Comments

github-actions[bot] · 26 days ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/44585
  2. https://github.com/anthropics/claude-code/issues/44253
  3. https://github.com/anthropics/claude-code/issues/48996

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

LAI0220 · 26 days ago

"This is not a duplicate — the linked issues are older and unresolved. Please escalate. I am unable to use Claude Code on Windows despite an active Pro subscription."

TranBaDat2607 · 25 days ago

I ran into the same issue.

You can check your ~/.claude/.credentials.json file and see whether refreshToken is empty. In my case, it was set to an empty string, which caused Claude Code to return 401 Invalid authentication credentials.

As a temporary workaround, I copied a valid refreshToken from another machine where the same Claude account was still working, and Claude Code started working again immediately.

infantilo · 25 days ago

Same for me: using claude code v2.1.185 Sonnet 4.6 claude pro subscription on linux getting the same error 401. still the same error after nearly 24h. no response from anthropics. maybe this is "geoblocking" non us citizen??

I dont have any other machine, so i'm stuck?
any solution from anthropics??

kevintraywick · 24 days ago

Same problem on a Mac in the U.S.
Desktop access works though, same a/c.

nakleh21 · 24 days ago

Same problem here, running on debian based OS

jocelynprevot · 24 days ago

Same issue on Claude Code v2.1.185, Pro subscription. UK based. Environment: GitHub Codespace (browser, on a Chromebook). Persistent 401 Invalid authentication credentials even after: deleting ~/.claude/.credentials.json, clearing ~/.config/claude and ~/.cache/claude, unsetting env vars, and generating a fresh setup-token. Fresh tokens still rejected. Pro plan active, weekly usage 5%, so not a quota issue. setup-token OAuth redirect goes to localhost which the cloud Codespace can't catch.

robgha01 · 24 days ago

Same issue here it suddenly broke down today

DanielClarkeDM · 24 days ago

Same, came in to work today and its not authenticating, which I've never had an issue with before

`` Please run /login · API Error: 401 Invalid authentication credentials``
I'm based in the UK as well.

LAI0220 · 24 days ago

I submitted a support ticket but never received a response.

Since Claude Code was still working on the desktop version, it suggested switching to API mode. However, there was no clear warning that API usage is billed separately on a pay-as-you-go basis. As a result, I ended up spending quite a bit of money before realizing it.

Fortunately, I eventually solved the issue. When I asked Opus 4.8 on the desktop version, it gave me the following solution on June 20:

In the Claude Code window, type /login and press Enter. This will open your browser and allow you to sign in to your Anthropic account again. After reauthorizing, your credentials will be refreshed and the 401 error should disappear.
If you still receive a 401 error after running /login, the most common causes are: 1. Old credentials were not fully cleared. Try logging out first. Close Claude Code, run claude logout in PowerShell (or manually delete the credential files), then reopen Claude Code and run /login again. 2. There is an issue with your subscription status. Check whether your Claude Pro subscription is still active in your billing settings on claude.ai. If your subscription was paused or payment failed, simply logging in again will not fix the problem. You must first restore your subscription.

Using the above method solved my issue completely.

What frustrated me is that when I previously used Sonnet 4.6, the troubleshooting suggestions it provided were completely ineffective. I spent a lot of API credits following those recommendations and got nowhere.

If anyone else is experiencing the same problem, I highly recommend trying the solution above before spending more money on API usage.

JCDB90 · 24 days ago

same issue here

DanielClarkeDM · 24 days ago

This worked for me. Thank you.

kevintraywick · 24 days ago

I don't get the opportunity to enter /login. it asks me to choose the text style then goes straight to method of log-in where i get 3 options: sub a/c, api or 3rd party. choosing sub a/c takes me to a web page that says i must upgrade to max. i'm on max now but choosing it as a plan takes me to payment. if i cancel the existing plan, i am still paying for 2 plans through my renewal date, JUly 8. so i'm waiting until june 7. i may try a pro plan and see if that works until then.

TranBaDat2607 · 24 days ago
e existing plan, i am still paying fo

Same bro. Me and two friends were sharing the account like you, and all of us got disconnected at the same time. Maybe Claude doesn't allow multiple people to use the same account anymore.

TranBaDat2607 · 24 days ago
I don't get the opportunity to enter /login. it asks me to choose the text style then goes straight to method of log-in where i get 3 options: sub a/c, api or 3rd party. choosing sub a/c takes me to a web page that says i must upgrade to max. i'm on max now but choosing it as a plan takes me to payment. if i cancel the existing plan, i am still paying for 2 plans through my renewal date, JUly 8. so i'm waiting until june 7. i may try a pro plan and see if that works until then.

if you have any solution pls tell me, I need my claude max 20x back :(

CAN-FA · 23 days ago

Still not resolved

care-planner25 · 21 days ago

Same issue. Windows 11, Max valid (org admin), env vars all empty, clean WinGet reinstall v2.1.187, /logout+/login and credential purge done. 401 persists for 48h. Support ticket open, no human response.

LucasZestScout · 19 days ago

I’m seeing the same 401 auth failure, but with an additional account-level onboarding loop.

Account state:

  • Active paid Claude Max 20x subscription
  • Existing Claude mobile session still works, so the account/history appear intact
  • New login attempts fail across other surfaces

Current failure:

  • claude.ai verifies my email, then redirects to /onboarding with “Let’s create your account”
  • Claude Desktop no longer works
  • Claude Code CLI returns: “Please run /login · API Error: 401 Invalid authentication credentials”
  • Running /login sends me back into the onboarding flow
  • VS Code extension also cannot authenticate

This is now day 3 of being locked out of a paid Max 20x account.

Troubleshooting already attempted:

  • Cleared claude.ai cookies/site data
  • Tried a completely fresh browser
  • Restarted machine
  • Retried login flows
  • Issue persists across browser, Desktop, CLI, and VS Code

Because my existing mobile session still works, this does not look like a deleted account or local cache issue. It looks like existing sessions remain valid, but new login/session issuance is broken, possibly due to server-side account mapping, onboarding state, or OAuth token issuance.

Support has not meaningfully responded for 2 days. Can someone from Anthropic confirm whether this auth/onboarding/401 class of issue is being tracked internally, and what support path can actually fix account mapping for paid users?

jocelynprevot · 19 days ago
Same issue on Claude Code v2.1.185, Pro subscription. UK based. Environment: GitHub Codespace (browser, on a Chromebook). Persistent 401 Invalid authentication credentials even after: deleting ~/.claude/.credentials.json, clearing ~/.config/claude and ~/.cache/claude, unsetting env vars, and generating a fresh setup-token. Fresh tokens still rejected. Pro plan active, weekly usage 5%, so not a quota issue. setup-token OAuth redirect goes to localhost which the cloud Codespace can't catch.

**UPDATE: It's been now more than a week since the 401 issue started. I have to relog (/login) every day - creating a new code every day - to reopen a claude pro sessio as a turnaround since the persistent CLAUDE_CODE_OAUTH_TOKEN on Github/codespace/secret is failing and is not being recognised by Claude Code.

CAN SOMEONE FROM ANTHROPIC CAN TAKE THIS ISSUE SERIOUSLY. We are paid users and this is disruptive of the daily workflows.**

yurukusa · 19 days ago

Not a maintainer — but this thread has two different 401s tangled together, and applying the wrong fix is why "logout / login / reinstall" isn't working for some of you. Splitting them:
Shape 1 — a stale/empty stored credential (the empty refreshToken @TranBaDat2607 found). When ~/.claude/.credentials.json has a blank refreshToken (or accessToken), the silent token refresh fails and every request 401s. The reason claude logout + deleting %APPDATA%\Claude / ~/.config/claude doesn't fix it for everyone: on macOS the credential also lives in the login Keychain (Keychain Access → search "Claude"), and on Windows in Credential Manager. logout is supposed to clear it, but when it doesn't, your fresh /login reads/writes the same stale entry. Fix: after claude logout, also delete the OS keychain / Credential Manager item and ~/.claude/.credentials.json, then /login. Copying a known-good .credentials.json from a working machine (as @TranBaDat2607 did) works because it bypasses the broken refresh — but clearing the keychain entry is the cleaner local fix.
Shape 2 — headless / remote where the OAuth callback can't be caught (@jocelynprevot's Codespaces / SSH / Chromebook case). /login opens a browser redirect to localhost, and a cloud/remote box has nothing listening there, so even freshly minted tokens never complete the handshake and get rejected. Don't keep regenerating tokens — run the claude setup-token flow (made for headless), or do the OAuth on a local machine and copy the resulting ~/.claude/.credentials.json over. The localhost-redirect limitation is the blocker, not your subscription.
One money warning for everyone here: several comments mention "switch to API mode" as a workaround. Don't — for a subscription 401, choosing the API-key option silently moves you onto pay-as-you-go billing (a commenter above lost real money this way). It isn't a fix for a subscription auth problem; it's a separate metered account path. Stay on the subscription login.
If, after clearing the keychain + json and re-authing, you still 401 on a confirmed-active Pro/Max plan (no payment failure under claude.ai → Billing), that points upstream. The single most useful detail to post then: your platform, and whether ~/.claude/.credentials.json repopulates with a non-empty refreshToken after /login — that one fact separates "client credential store is broken" (Shape 1, fixable locally) from "token issuance is failing server-side" (not yours to fix).

baton · 18 days ago

Seem to have the same problem on Mac starting v2.1.191. Manually fall back to v2.1.187 as workaround.

majerus1223 · 7 days ago

Same issue