[BUG] Unable to Login

Open 💬 34 comments Opened Mar 11, 2026 by adam-badar

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?

<img width="1173" height="566" alt="Image" src="https://github.com/user-attachments/assets/0f5cae09-36b4-4959-a6d4-04b43c866be5" />

The browser says authenticated, but claude code gives a OAuth error. I'm on the Max plan. I am unable to use claude code at all. There seems to be a lot of lag even in the authentication process itself

<img width="1285" height="296" alt="Image" src="https://github.com/user-attachments/assets/6a6e2206-5fec-49b9-a829-adc127660427" />

What Should Happen?

It should log me in.

Error Messages/Logs

Steps to Reproduce

  1. /login in claude code
  2. click authorize in browser
  3. claude code throws OAuth error

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.72

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

34 Comments

RaufGlasgow · 4 months ago

Same problem

gocyclic249 · 4 months ago

Same here

TheSentiTrader · 4 months ago

+1

patrykiciak-st · 4 months ago

+1

robert-mauck · 4 months ago

same problem. I was. looking at DNS:

DNS Verification
accounts.anthropic.com returns NXDOMAIN from both local DNS and Google's public resolver:
$ dig accounts.anthropic.com

; <<>> DiG 9.10.6 <<>> accounts.anthropic.com
;; QUESTION SECTION:
;accounts.anthropic.com. IN A

;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 47159
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; AUTHORITY SECTION:
anthropic.com. 1800 IN SOA isla.ns.cloudflare.com. dns.cloudflare.com. 2398319840 10000 2400 604800 1800

;; SERVER: 192.168.1.1#53
$ nslookup accounts.anthropic.com 8.8.8.8
Server: 8.8.8.8
Address: 8.8.8.8#53

** server can't find accounts.anthropic.com: NXDOMAIN
Note: claude.ai and api.anthropic.com both resolve and connect normally. Only accounts.anthropic.com is missing.

luxemque · 4 months ago

Same problem, tried several times, got a code to paste every 5th time but Claude Code always ran into timeout.

lollater-coder · 4 months ago

same

github-actions[bot] · 4 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/33239
  2. https://github.com/anthropics/claude-code/issues/33214
  3. https://github.com/anthropics/claude-code/issues/33246

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

LukeLIN-web · 4 months ago

+1

asotog · 4 months ago

+1

tperelle · 4 months ago

+1

doshacham · 4 months ago

great shit antrhopic +1 thanks for wasting tokens.

NicholasWM · 4 months ago

+1

alexania · 4 months ago

+1

AngelGiampierre · 4 months ago
emre-onal · 4 months ago

lets solve ai incident quickly using ai

MintCollector · 4 months ago

+1

amandeavor · 4 months ago

Root Cause (Likely)

Claude Code CLI authentication uses an OAuth flow through the browser. The browser successfully authenticates the account, but the CLI fails when receiving or validating the OAuth callback token.

This mismatch usually occurs when:

  1. The CLI is waiting for the OAuth callback on a local port but fails to receive it.
  2. The callback token expires before the CLI processes it (often due to lag in the auth flow).
  3. The CLI version introduces a regression in the OAuth callback handler.

Since the browser shows authenticated but the CLI throws an OAuth error, the failure likely happens after authorization, during token exchange or callback handling.

---

Proposed Fix

Improve OAuth callback handling in the CLI by:

  1. Ensuring the CLI correctly listens for the OAuth redirect.
  2. Adding retry logic for token exchange failures.
  3. Increasing timeout tolerance for slow authentication flows.

---

Example Fix (TypeScript)

Improve OAuth Callback Listener

Ensure the local server waits long enough for the redirect.

const AUTH_TIMEOUT = 120000; // increase timeout to 120s

server.listen(port);

const timeout = setTimeout(() => {
  reject(new Error("OAuth authentication timeout"));
}, AUTH_TIMEOUT);
Handle Token Exchange Errors Gracefully

Add retry logic when exchanging the authorization code.

async function exchangeToken(code: string) {
  for (let attempt = 0; attempt < 2; attempt++) {
    try {
      return await requestAccessToken(code);
    } catch (err) {
      if (attempt === 1) throw err;
    }
  }
}
Ensure Redirect URL Matches Expected Callback

Verify the CLI registers the same redirect URI used during authorization.

Example:

http://localhost:PORT/oauth/callback

If the redirect URI differs, the OAuth flow will succeed in the browser but fail in the CLI.

Additional Defensive Handling

Add validation to detect the "browser authenticated but CLI failed" state:

if (!authCode) {
  throw new Error(
    "OAuth authentication succeeded in the browser but the CLI did not receive the callback."
  );
}

This prevents silent failures and gives a clearer error message.

Expected Result After Fix

/login opens the browser.

User authorizes successfully.

CLI receives the OAuth callback.

Access token is exchanged and stored locally.

Claude Code CLI finishes authentication successfully.

Impact

Fixes login failures in Claude Code 2.1.72.

Improves reliability of OAuth authentication.

Prevents timeout-related login errors during slower authentication flows.
carlguo866 · 4 months ago

+1

tpzub · 4 months ago

+1

Timpers · 4 months ago

+1

LaytonGott · 4 months ago

Same problem here

ZhangYeSong · 4 months ago

+1

Hegenderfer · 4 months ago

+1

Daniel-Timms · 4 months ago

+1

Duvet05 · 4 months ago

Same issue on EndeavourOS (Arch-based), Lima, Peru. Claude Code 2.1.72, installed via npm + nvm.

Environment:

  • OS: EndeavourOS / kernel 6.19.6-arch1-1
  • Node: v22.14.0 (nvm)
  • Shell: bash 5.3.9
  • Can log in via claude.ai web browser ✅
  • /login in CLI fails with OAuth error: timeout of 15000ms exceeded

Workaround confirmed working for Linux/nvm users:

# Find the file
CLI=$(find ~/.nvm/versions/node -name 'cli.js' -path '*claude-code*')
echo "Patching: $CLI"

# Apply the timeout fix
sed -i 's/timeout:15000/timeout:45000/g' "$CLI"
sed -i 's/AbortSignal.timeout(15000)/AbortSignal.timeout(45000)/g' "$CLI"

After patching, /login completes successfully. This confirms the issue is not specific to Windows — it affects Linux users in Latin America as well, likely due to regional latency on the OAuth callback endpoint.

jsun-clariti · 4 months ago

+1

JDonaghy · 4 months ago

The patch fix did not work for me on Ubuntu. As soon as the browser finally responds saying "Build something great..." the CLI reports OAuth error timeout exceeded even at 45000ms.

tpzub · 4 months ago

I was successful with:

  1. npm install -g @anthropic-ai/claude-code@2.1.66
  2. /login (Successful login)
  3. npm install -g @anthropic-ai/claude-code

I don't know if it was a coincidence, but I'm logged in now

JDonaghy · 4 months ago

2.1.66 also worked for me, thanks @tpzub

TechBEK · 4 months ago
I was successful with: 1. npm install -g @anthropic-ai/claude-code@2.1.66 2. /login (Successful login) 3. npm install -g @anthropic-ai/claude-code I don't know if it was a coincidence, but I'm logged in now

I did this (without -g) in conjunction to https://github.com/anthropics/claude-code/issues/33247#issuecomment-4040530566 (timeout adjust).. which worked well enough to get my login back and from there, I resumed on the latest version of claude code..

jusunglee · 4 months ago

Setup claude token claude setup-token in your zshrc to avoid this oauth nonsense in the future

xbtmatt · 4 months ago

This sounds silly and it might not apply to everyone, but I had a stale auth token set in my start up config in my terminal. Since I use VSCode with my fish terminal, it was also loading this invalid Auth token.

VSCode requires a restart to reload environment variables so...

  1. Ensure you've removed export CLAUDE_CODE_AUTH_TOKEN="...", set -x CLAUDE_CODE_AUTH_TOKEN "..." and the like from any of your terminal startup scripts.
  2. Restart your computer
  3. Re-authenticate through the typical means (VSCode login sequence, claude setup-token, etc
56badkarma · 3 months ago

Had the same issue this morning. Mix of 500 and timeout errors. Must have tried more tha a dozen times.
What worked for me:

  • Switch from Opus4.6 1M context -> Sonnet4.6
  • Run /login -> select Claude account with subscription
  • Close out auto Browser Tab open from OAuth flow before it can navigate
  • Copy/Paste the URL and manually navigate -> Click "Authorize"
  • Copy/Paste code into terminal

I got a timeout error on the first attempt, but second time finally succeeded.