claude-code - 💡(How to fix) Fix [BUG] macOS sleep/wake causes 401 authentication errors requiring full reboot

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

API Error: 401 Invalid authentication credentials Please run /login

Code Example

API Error: 401 Invalid authentication credentials
Please run /login
RAW_BUFFERClick to expand / collapse

Preflight Checklist

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

What's Wrong?

After MacBook Pro sleep/wake, Claude Code consistently returns 401 authentication errors. Only full macOS reboot resolves the issue.

Environment:

  • macOS (MacBook Pro)
  • Claude Code v2.1.142
  • This persists despite the v2.1.137 Keychain race condition fix

Steps to Reproduce:

  1. Use Claude Code normally (works fine)
  2. Close MacBook Pro lid (sleep)
  3. Open MacBook Pro (wake)
  4. Try to use Claude Code → 401 error every time

What I've tried (none work):

  • Deleting ~/.claude/.credentials.json and re-login
  • macOS logout/login
  • Only full macOS REBOOT fixes the issue

This suggests a deeper macOS system-level problem beyond the Keychain race condition fixed in v2.1.137. The securityd service appears to require a full system restart to resynchronize with Claude Code's OAuth tokens after sleep.

What Should Happen?

Sleep/wake cycles should not break Claude Code authentication. Users should be able to close and open their MacBook Pro without requiring a full system reboot.

Error Messages/Logs

API Error: 401 Invalid authentication credentials
Please run /login

Steps to Reproduce

  1. Use Claude Code normally on macOS (works fine)
  2. Close MacBook Pro lid to sleep
  3. Wait (any duration)
  4. Open MacBook Pro lid (wake from sleep)
  5. Open Claude Code
  6. Send any prompt → 401 authentication error occurs
  7. Try /logout then /login → 401 persists
  8. Delete ~/.claude/.credentials.json and re-login → 401 persists
  9. Only full macOS reboot resolves the issue

Claude Model

Sonnet (default)

Is this a regression?

No, this never worked

Last Working Version

No response

Claude Code Version

v2.1.142

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

VS Code integrated terminal

Additional Information

No response

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] macOS sleep/wake causes 401 authentication errors requiring full reboot