Skip to Content

Claude Code Session Expired Fix: Login & Auth Errors (2026)

June 1, 2026 by
aliakram

🔑 Quick Answer: What Is the Claude Code Session Expired Error?

When Claude Code shows a “session expired” or “OAuth token has expired” error, it means Claude Code can no longer authenticate your current session with Anthropic.

The fastest fix is usually:

/logout
/login

If /login works but the error keeps returning, check your active authentication method, system clock, credential storage, browser/OAuth flow, and environment variables.

The most common causes include:

  • Expired or revoked OAuth credentials
  • Failed automatic token refresh
  • Incorrect system time
  • macOS Keychain problems
  • OAuth callback or browser issues
  • A conflicting ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN
  • Account, organization, or subscription changes
  • Temporary Anthropic service outages
  • Remote or SSH/WSL authentication problems

Anthropic's current error reference specifically lists OAuth token revoked, OAuth token has expired, Login expired, and Not logged in · Please run /login as authentication errors.

1. What Is the Claude Code Session Expired Error?

The Claude Code session expired error appears when Claude Code can no longer use the credentials associated with your current authentication session.

For subscription users, Claude Code normally authenticates through a browser-based OAuth flow. You start Claude Code, authenticate through your Claude account in the browser, and Claude Code stores the resulting credentials for future use.

When those credentials expire, are revoked, cannot be refreshed, or cannot be accessed locally, Claude Code may stop making authenticated requests.

You may see messages such as:

Login expired · Please run /login

or:

OAuth token has expired · Please run /login

You can also encounter:

OAuth token revoked · Please run /login

or:

Not logged in · Please run /login

These messages all point toward an authentication problem, although the underlying cause can be different.

When authentication fails, Claude Code may no longer be able to:

  • Send authenticated requests to Anthropic
  • Validate your account and permissions
  • Use your Claude subscription through the CLI
  • Generate AI responses
  • Continue normal Claude Code workflows
  • Reconnect certain remote sessions

📌 Official Source — Anthropic Support

Anthropic recommends checking the exact error first rather than assuming that every failure is a token-expiration problem.

For authentication issues, /status can show which credential is currently active. Anthropic also recommends /doctor for diagnosing local configuration problems and checking the official status page when a service-side problem may be involved.

2. Why Does the Claude Code Session Expired Error Happen?

There isn't one single cause. Several authentication and environment problems can produce similar symptoms.

2.1 OAuth Token Expired or Refresh Failed

This is the most direct cause.

When you authenticate with your Claude account, Claude Code uses OAuth credentials. Access credentials are time-limited, and Claude Code normally attempts to maintain authentication without requiring you to log in every time.

Anthropic's current documentation describes an expired OAuth token as a situation where the saved login is no longer valid and the automatic refresh failed.

The error can look like:

OAuth token has expired · Please run /login

Fix

Run:

/login

Then complete the browser authentication flow.

If the problem returns immediately after logging in again, use:

/logout
/login

Anthropic specifically recommends logging out first when re-authentication does not stick within the same session.

2.2 OAuth Token Was Revoked

An expired token and a revoked token are not exactly the same.

A token can be revoked because your authentication state changed—for example, an account administrator may remove access, or the session may be invalidated elsewhere.

Claude Code reports this separately:

OAuth token revoked · Please run /login

The solution is still to authenticate again:

/login

If that doesn't work:

/logout
/login

2.3 OAuth Callback Timeout or Browser Login Failure

Claude Code's OAuth authentication depends on communication between your terminal and browser.

Normally, Claude Code starts the browser authentication flow and receives the result back through its local callback mechanism.

Problems can occur when:

  • The browser cannot reach the local callback
  • You're using SSH
  • You're running Claude Code inside WSL2
  • You're inside a container
  • The browser is running on a different machine
  • The OAuth URL is truncated or copied incorrectly
  • A proxy, VPN, or firewall interferes with the request

Anthropic specifically documents WSL2, SSH, and container environments as cases where the browser may be unable to reach Claude Code's local callback server.

Fix

If the browser does not open automatically, Claude Code lets you copy the authentication URL and open it manually.

Press:

c

when prompted during authentication to copy the OAuth URL.

For remote environments, make sure you're completing the authentication flow in the correct browser/host.

2.4 macOS Keychain Problems

This cause is specific to macOS.

Claude Code stores credentials in the encrypted macOS Keychain. If the Keychain is locked, unavailable, or its password is out of sync, Claude Code may be unable to read or save authentication credentials.

This can create a confusing situation:

You successfully log in, but Claude Code asks you to log in again later.

The problem may not be the OAuth account itself. Claude Code may simply be unable to persist or access the credentials locally.

Fix

First run:

claude doctor

Anthropic recommends this for checking Keychain access.

If necessary, unlock the login Keychain:

security unlock-keychain ~/Library/Keychains/login.keychain-db

You can also open Keychain Access and check whether the login keychain is locked or needs its password synchronized.

2.5 Incorrect System Clock

OAuth credentials are time-sensitive.

If your computer's system clock is significantly incorrect, a valid credential can appear expired or invalid because the timestamps used during authentication no longer line up correctly.

Anthropic specifically recommends checking that your system clock is accurate when login prompts happen repeatedly.

Fix

Make sure:

  • Date and time are correct
  • Automatic time synchronization is enabled
  • Your timezone is configured correctly
  • A VM or remote server isn't drifting significantly from real time

After correcting the clock, restart Claude Code and try:

/login

2.6 Conflicting API Keys

This is one of the easiest causes to overlook.

Claude Code supports multiple authentication methods, and environment variables can take precedence over your subscription OAuth login.

For example, if you have:

ANTHROPIC_API_KEY

set in your shell, Claude Code may use that credential instead of the subscription credentials you authenticated with through /login.

Anthropic explicitly documents this precedence behavior.

This can produce a frustrating loop:

  1. You run /login
  2. Browser authentication succeeds
  3. Claude Code still uses an environment API key
  4. The request fails
  5. You think the new OAuth session is broken

Check Your Environment

On macOS/Linux:

env | grep ANTHROPIC

If you find an old API key that you don't need, temporarily remove it:

unset ANTHROPIC_API_KEY
unset ANTHROPIC_AUTH_TOKEN

Then restart Claude Code:

claude

Check the active authentication method with:

/status

Anthropic recommends /status specifically for determining which credential is active.

Windows PowerShell

Check:

Get-ChildItem Env:ANTHROPIC*

If an unwanted credential is configured, remove it from your PowerShell profile or Windows environment variables, then restart your terminal.

2.7 CLAUDE_CODE_OAUTH_TOKEN Can Override Stored Credentials

There is another authentication variable developers should know about:

CLAUDE_CODE_OAUTH_TOKEN

Anthropic documents this as an OAuth access token that can be used instead of the normal /login flow. It takes precedence over credentials stored in the keychain.

That means an old or expired environment token can cause authentication problems even after you successfully log in through /login.

If you're using this variable, verify that it is intentional and still valid.

For automated environments, Anthropic also documents:

CLAUDE_CODE_OAUTH_REFRESH_TOKEN
CLAUDE_CODE_OAUTH_SCOPES

as a way to provision renewable OAuth authentication without relying on an interactive browser flow.

3. A Real-World Issue: OAuth Sessions Expiring After ~8 Hours

This isn't always something you've misconfigured.

In June 2026, a Claude Code GitHub issue reported OAuth sessions expiring approximately every eight hours and requiring users to run /login again. The report described a refreshToken being present while the access token still expired and the refresh flow did not behave as expected. The issue was marked closed as a duplicate, so it should be treated as evidence of a reported product issue rather than proof that every user's session has the same bug.

This is important because it changes how you troubleshoot.

If:

  • /login works
  • Your subscription is active
  • Your clock is correct
  • Your credentials are stored correctly
  • No conflicting API key is being used

but Claude Code repeatedly asks you to authenticate after a predictable period, the problem may be related to the authentication implementation rather than your local configuration.

What Should You Do?

Don't repeatedly reinstall Claude Code.

Instead:

/status

Then:

/logout
/login

If the problem continues across launches, record:

  • Claude Code version
  • Operating system
  • Authentication method
  • Exact error message
  • Approximate time between successful login and expiry

Then check the Claude Code GitHub issues and Anthropic's status page.

4. How to Fix Claude Code Session Expired Error

Work through these fixes in order. Start with the simplest one.

Fix 1: Run /login

Inside Claude Code:

/login

Complete the browser authentication flow.

This is the official first-line solution for an expired OAuth token.

Fix 2: Log Out Completely and Log In Again

If /login doesn't fix the problem:

/logout

Then:

/login

Anthropic recommends this clean re-authentication flow when the saved credential remains invalid after a normal login.

Fix 3: Check Which Credential Claude Code Is Using

Run:

/status

This helps identify whether Claude Code is using:

  • Subscription OAuth
  • API credentials
  • Another authentication method

This step is especially important if you use both Claude subscriptions and Anthropic API keys.

Fix 4: Check for Conflicting Environment Variables

Run:

env | grep ANTHROPIC

Look for:

ANTHROPIC_API_KEY
ANTHROPIC_AUTH_TOKEN
CLAUDE_CODE_OAUTH_TOKEN

If you intended to use subscription authentication but an old API credential is present, remove the conflicting variable and restart Claude Code.

For example:

unset ANTHROPIC_API_KEY
unset ANTHROPIC_AUTH_TOKEN

Then:

claude

Finally:

/status

to verify the active credential.

Fix 5: Run claude doctor

Claude Code includes a diagnostic command:

claude doctor

Use it when the basic login cycle doesn't solve the problem.

It can help identify local configuration and authentication-related problems. Anthropic recommends claude doctor when an issue persists after the basic troubleshooting steps.

Fix 6: Check Your System Time

Verify that your computer has the correct:

  • Date
  • Time
  • Timezone

Enable automatic time synchronization if necessary.

Then restart Claude Code and authenticate again:

/login

This is particularly worth checking when the session appears to expire repeatedly.

Fix 7: Check macOS Keychain

If you're on macOS and authentication keeps disappearing, inspect the Keychain.

Run:

claude doctor

If the login keychain is locked, you can try:

security unlock-keychain ~/Library/Keychains/login.keychain-db

Then restart Claude Code.

Anthropic notes that Keychain locking or a password mismatch can prevent Claude Code from saving credentials correctly.

Fix 8: Try Without VPN or Proxy

Network configuration can interfere with OAuth authentication and API requests.

If you're using:

  • VPN
  • Corporate proxy
  • Firewall
  • Network filtering software

temporarily test the login without it.

Anthropic's troubleshooting documentation specifically covers proxy, firewall, OAuth, and network-related login failures.

Fix 9: If You're Using SSH, WSL2, or a Container

OAuth can behave differently in remote environments because the browser and Claude Code may run on different machines.

Anthropic specifically notes this for WSL2, SSH sessions, and containers.

If the browser cannot complete the callback automatically, copy the authentication URL and open it from the appropriate browser.

In remote/headless environments, consider using an authentication method designed for automation instead of relying on an interactive browser login.

For subscription-based automation, Anthropic documents claude setup-token, which creates a one-year OAuth token for supported plans.

5. Don't Confuse Session Expiration With a Claude Code Outage

Sometimes the problem isn't your session at all.

Claude Code can experience:

  • API outages
  • Authentication service incidents
  • Network failures
  • Server errors
  • Capacity problems
  • Regional issues

For example, community reports during a March 2026 incident showed users experiencing both login timeouts and session-expired messages at the same time. That demonstrates why it's important to check service status before changing local configuration.

Check the Official Status Page First

Before deleting credentials or reinstalling Claude Code, check:

status.anthropic.com

If Anthropic is experiencing an active incident, repeatedly logging in may not solve the problem.

A useful troubleshooting sequence is:

1. Check Anthropic status
2. Check /status
3. Run /login
4. Try /logout → /login
5. Check environment variables
6. Run claude doctor

Anthropic's own error reference also recommends checking the service status and GitHub issues when the documented fixes don't resolve the problem.

6. What If You Get a 401 or 403 Instead?

Not every authentication-looking error means your OAuth token simply expired.

401 Unauthorized

A 401 generally points to an authentication problem.

For example:

API Error: 401
authentication_error

Possible causes include:

  • Expired OAuth token
  • Invalid API key
  • Revoked credential
  • Wrong authentication method

Anthropic recommends checking the active credential and re-authenticating when appropriate.

403 Forbidden

A 403 can indicate an authorization or access problem rather than a simple expired token.

For example, your account may authenticate successfully but lack permission for a particular organization or feature.

Anthropic's troubleshooting guide recommends checking your subscription or organization permissions and investigating proxy interference when a 403 occurs after login.

7. What If /login Doesn't Work?

If /login itself fails, don't immediately assume your Claude subscription is broken.

Try these steps:

Step 1 — Close Claude Code

Exit the current session.

Step 2 — Start Claude Code Again

claude

Step 3 — Start a Clean Login

/login

Step 4 — If Necessary, Log Out First

/logout
/login

Step 5 — Check the Browser

If the browser doesn't open automatically, copy the OAuth URL and open it manually.

Step 6 — Check Your Network

Temporarily test without a VPN, proxy, or restrictive firewall.

Step 7 — Check Diagnostics

claude doctor

Anthropic's current troubleshooting flow specifically recommends clean re-authentication, manual OAuth URL handling, system-clock checks, Keychain checks, and claude doctor depending on the failure.

8. When Should You Stop Troubleshooting Locally?

If you've already tried:

/logout
/login

and:

  • Your account is active
  • /status shows the expected credential
  • Your system clock is correct
  • No conflicting environment credential is present
  • Keychain/storage is working
  • Your network is fine
  • Anthropic's status page shows no active incident

then continuing to randomly delete files or reinstall Claude Code is unlikely to help.

At this point, collect the exact error and diagnostic information.

If Claude Code can start a session, Anthropic recommends:

/feedback

You can also run:

claude doctor

and check existing GitHub issues for known problems.

9. How to Prevent Claude Code Authentication Problems

You can't prevent every server-side authentication issue, but you can reduce local problems.

Keep One Authentication Method Clear

If you're using a Claude subscription through /login, avoid leaving an unnecessary:

ANTHROPIC_API_KEY

in your environment.

Claude Code's authentication precedence means that environment credentials can override subscription credentials.

Keep Your System Clock Synchronized

This is especially important on:

  • Virtual machines
  • Remote servers
  • WSL environments
  • Machines that frequently sleep or suspend

Don't Ignore Repeated Login Prompts

If Claude Code asks you to authenticate repeatedly, don't assume that's normal.

Check:

/status

and:

claude doctor

Repeated authentication can point to a credential-storage, environment, or product-level issue.

Keep Claude Code Updated

If you're experiencing an authentication bug that others have also reported, check the current Claude Code release and GitHub issues before spending hours modifying your configuration.

10. Quick Troubleshooting Checklist

If Claude Code suddenly says your session expired, follow this checklist:

First attempt

/login

If it happens again

/logout
/login

Check authentication

/status

Check diagnostics

claude doctor

Check environment credentials

env | grep ANTHROPIC

Check your system clock

Make sure automatic date/time synchronization is enabled.

macOS users

Check the login Keychain and run:

security unlock-keychain ~/Library/Keychains/login.keychain-db

Remote users

If you're using SSH, WSL2, or containers, check whether the browser OAuth callback can reach the machine running Claude Code.

Finally

Check Anthropic's status page and Claude Code's GitHub issues before assuming your installation is broken.

11. Final Verdict

The Claude Code Session Expired error is primarily an authentication problem, not a coding problem.

In the simplest case, the solution is:

/logout
/login

But if the error keeps returning, look beyond the token itself. Check your system clock, macOS Keychain, environment variables, OAuth callback, remote environment, account permissions, and Anthropic service status.

One particularly important lesson from reported 2026 issues is that recurring session expiration can sometimes be a Claude Code authentication bug rather than something wrong with your machine.

So don't waste time reinstalling Claude Code when the actual problem is authentication.

Start with:

/status

then:

/logout
/login

and use:

claude doctor

if the problem persists.

That gives you a much faster path from “Session expired” to knowing whether the problem is your credentials, your machine, your network, or Anthropic's service.