Skip to main content
Claudebeginner

Fix "Failed to refresh OAuth token: another Claude Code process is refreshing it"

Fix "Failed to refresh OAuth token: another Claude Code process is refreshing it or exited mid-refresh". Clear the stale refresh lock, find the competing process, and stop it recurring.

7 min readUpdated September 2026

If Claude Code prints this, do exactly what the message says first — wait a minute and run the command again:

Failed to refresh OAuth token: another Claude Code process is refreshing it
or exited mid-refresh. This is usually transient; retry in a minute, and if
it persists close other Claude Code processes or sign in again.

In the common case that is the whole fix, and nothing is wrong with your account or your install.

Here is what the message is telling you. Before Claude Code renews your OAuth token it takes a short lock on the credential store, so that two sessions cannot write it at once and leave you with a half-written token. This error means the lock was already held when your session wanted it. There are only two ways that happens:

  • A second session is genuinely refreshing right now. It finishes in seconds and releases the lock. Retrying works.
  • A previous session died while holding the lock. Nothing will ever release it, so every command from now on prints this message. Retrying does not work.

The retry is therefore the diagnostic as well as the fix. If one retry clears it, stop here. If the second attempt fails the same way, you have a stale lock and the rest of this page applies.

Fix a stale lock

Step 1: Find every Claude Code process

The message says to close other Claude Code processes, and the reason people get stuck here is that they close the terminal windows they can see and miss the ones they cannot.

# macOS and Linux
pgrep -fl claude
# Windows PowerShell
Get-Process | Where-Object { $_.ProcessName -like "*claude*" }

Expect to find more than you opened. IDE extensions keep a background process alive independently of any visible panel, and so do MCP servers, background agents and any CI or cron job that shells out to claude.

Step 2: Close them all

Quit your editor completely rather than closing the Claude panel — a running editor restarts its background process immediately and retakes the lock as fast as you clear it. Then confirm nothing is left:

pgrep -fl claude || echo "none running"

If a process refuses to exit, end it explicitly and re-check:

pkill -f claude
pgrep -fl claude || echo "none running"

Step 3: Re-authenticate to rewrite the credentials

With nothing running, sign in again. This writes a fresh token and clears the lock state along with it:

claude auth login

Or, from inside a session, use the slash command:

/login

Then confirm:

claude auth status
Advertisement

Step 4: If it still fails, reset the credential state

If claude auth login itself reports the same locking error with no Claude Code process running anywhere, the stored state is inconsistent. Move it aside rather than deleting it, so you can restore it if this was not the cause:

mv ~/.claude/.credentials.json ~/.claude/.credentials.json.bak
claude auth login

Your settings, history and project configuration live elsewhere in ~/.claude and are untouched by this. On macOS, if the token is held in the login Keychain instead, search it for the Claude Code entry in Keychain Access and delete that item before logging in again.

Stop it recurring

Most repeat cases come from one of three setups.

Shared credentials across containers. Mounting your host ~/.claude into a devcontainer — or into several at once — gives independent Claude Code installs a single credential file with no coordination between them. They will contend indefinitely. Give each container its own configuration directory and authenticate it separately rather than sharing the host's.

A session on networked or synced storage. A ~/.claude on NFS, SMB, or a folder synced by Dropbox, iCloud Drive or OneDrive breaks the locking that this mechanism depends on, and the sync client can also restore a stale lock file after you clear it. Keep the configuration directory on local disk.

Unattended jobs running as you. A cron job, CI runner or scheduled agent invoking claude with your credentials will contend with your interactive sessions at unpredictable times. Give automation its own authentication rather than borrowing yours.

The error this is not

Two OAuth messages look similar and have opposite fixes:

MessageWhat it means
another Claude Code process is refreshing itLock contention during renewal. Your login is valid. Retry, then clear stale processes.
OAuth session expired and could not be refreshedThe session genuinely lapsed and renewal was refused. You must sign in again.

If yours is the second, OAuth token has expired covers it, including the API-key conflict and system-clock causes that make a valid login look expired.

Frequently Asked Questions

Find answers to common questions

Claude Code takes a short lock before it renews your OAuth token, so two sessions cannot write the credential file at the same time. This message means the lock was already held. Either a second session is genuinely mid-refresh, or a previous one was killed while holding the lock and never released it.

Usually not. The message says "this is usually transient" for a reason - when a real second session holds the lock, it releases within seconds and the next command succeeds. It only becomes a real problem when a stale lock survives a crash, in which case it repeats on every command until you clear it.

A retry that still fails means the lock is stale rather than contended. Close every Claude Code process, confirm none are left with "pgrep -fl claude", then run /login inside a new session, or "claude auth login" from your shell, to rewrite the credentials cleanly.

IDE extensions keep a background Claude Code process alive that you never see, so a terminal session and the editor compete for the same credential file. Quit the editor entirely - not just the panel - before troubleshooting, or the background process will retake the lock as fast as you clear it.

Yes, and it is the most reliable way to reproduce it. Mounting your host ~/.claude into one or more containers gives several independent Claude Code installs one shared credential file with no coordination between them. Give each container its own credentials directory instead of sharing the host's.

No. This is a locking failure during renewal, not an expiry. The separate message "OAuth session expired and could not be refreshed" is the expiry case and needs a real re-login.

In your Claude Code configuration directory, ~/.claude, on macOS and Linux, and in the equivalent user profile directory on Windows. On macOS the token itself may sit in the login Keychain with ~/.claude holding the surrounding state.

Several sessions wake at once and all discover the same near-expired token at the same moment, so they all try to refresh together. One wins and the rest print this message. That is the benign case - retry once and it clears.

No. Parallel sessions are fine in normal use. The message only appears in the narrow window where two of them try to renew the same token simultaneously, which is why it is most visible right after a long idle period or a resume from sleep.