Fix "Login reached its time limit · Please run /login" overnight
If Claude Code stopped overnight on "Login reached its time limit · Please run /login", "Login expired · Please run /login", or "Authentication failed", your login session timed out while you were away. The run halted on an error with no alert.
Lidnight stops runaway spend, silent approval stalls, and unexpected limit hits while you step away. Track Claude Code, Codex, Antigravity, Gemini and Kiro sessions, limits and cost, approve from your phone, and keep going with the lid closed.
Lidnight is a Mac app, so it can't be installed on this device. Open this address on your Mac to download it.
Copied. Paste it on your Mac to open it.
Couldn't copy. Tap the address below to select it, then copy.
If you saw a warning that your login is about to expire
From Claude Code 2.1.203 on, it warns ahead of time when the saved login is about to expire. The official changelog says it added a warning so you can re-authenticate before background sessions are interrupted (the on-screen wording can differ by version). If you see it, run /login before you hand off an overnight job and the run won't stop halfway on an expired login.
Once it has expired, the Login row in /status reads Expired — log in again. The row appears only when the saved login is your active credential and can no longer be refreshed (Claude Code error docs).
Why it happens
Claude Code signed in with a Claude subscription uses a short-lived access token and renews it with a stored refresh token. If the renewal fails (the sign-in is rejected as too old, or several sessions and the desktop app race the same refresh token), the next request ends in an auth error and the turn stops there. At the keyboard it's one /login; an overnight run just sits until morning.
Plenty of people have hit it: subagents stopped for 8.5 hours after a login expired at night (#104806), the desktop app stuck on "Authentication failed - sign in again" with no remote recovery (#106089), concurrent sessions clobbering the refresh token and wiping the Keychain login (#88583), and a long-standing request for token refresh in autonomous workflows (#12447).
Handling it yourself
1. Get told the moment it stops: when a turn ends on an API error, Claude Code runs the StopFailure hook with a value such as authentication_failed in the input JSON's error. Register it in ~/.claude/settings.json as below and have the script call osascript -e 'display notification "run /login" with title "Claude Code stopped"'. For your phone, add curl -d "run /login" https://ntfy.sh/<your-topic> to the same script. A ready-made script: stop-failure-alert.sh.
{ "hooks": { "StopFailure": [ { "matcher": "authentication_failed",
"hooks": [ { "type": "command", "command": "~/.claude/hooks/stop-failure-alert.sh" } ] } ] } }Limits: on Claude Code 2.1.317 we confirmed authentication_failed reaching the hook with an invalid key; a real subscription login expiring mid-night, and failures only inside subagents, weren't reproduced. The alert only tells you; it can't log you back in.
2. Make expiry less likely: if you run unattended often, claude setup-token creates a long-lived auth token (Claude subscription required). Treat it like a password and keep it out of shell history and repos. Many concurrent sessions plus the desktop app can race the refresh (#88583), so running fewer sessions overnight also helps.
With Lidnight
Lidnight adds a StopFailure hook to Claude Code when you set it up, so it recognises a session that ended on a login error and shows a "Stopped, logged out: <project>" Mac notification right away (free; the "Looks stuck" alert in Settings, on by default). For older sessions without the hook and for Codex, it reads the error text in the transcript (/login, 401 and so on). With Pro the same alert also goes to your phone (ntfy). It keeps this separate from usage limits, so a session waiting on a limit isn't reported as a login problem. Logging back in is still up to you. Checking what Claude Code did while you were away
Try Lidnight free
Apple Silicon Macs · macOS 13 or later. Every download includes a free trial of everything in Pro (14 days or 5 lid-closed runs of 10+ minutes, whichever comes first), no payment details needed. Pro is a one-time payment (1 Mac $9.99 · 3 Macs $14.99 USD, plus regional tax) with a 14-day full refund, no questions asked.
Lidnight is a Mac app, so it can't be installed on this device. Open this address on your Mac to download it.
Copied. Paste it on your Mac to open it.
Couldn't copy. Tap the address below to select it, then copy.