[BUG] macOS sleep/wake causes 401 authentication errors requiring full reboot

Resolved 💬 8 comments Opened May 18, 2026 by hidekinakazato-sys Closed Jun 23, 2026

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:

  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_

View original on GitHub ↗

This issue has 8 comments on GitHub. Read the full discussion on GitHub ↗