[BUG] macOS sleep/wake causes 401 authentication errors requiring full reboot
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?
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:
- Use Claude Code normally (works fine)
- Close MacBook Pro lid (sleep)
- Open MacBook Pro (wake)
- 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
- Use Claude Code normally on macOS (works fine)
- Close MacBook Pro lid to sleep
- Wait (any duration)
- Open MacBook Pro lid (wake from sleep)
- Open Claude Code
- Send any prompt → 401 authentication error occurs
- Try /logout then /login → 401 persists
- Delete ~/.claude/.credentials.json and re-login → 401 persists
- 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_
This issue has 8 comments on GitHub. Read the full discussion on GitHub ↗