Guide · October 2026

Claude Code keeps retrying in DarkWake after lid close

If you closed the lid, woke up to a smaller limit and see "Connection lost while your computer was asleep" over and over, Claude Code was re-sending requests during the brief DarkWakes your Mac does while asleep.

Why it happens

A Mac asleep with the lid closed still wakes for a few seconds every few minutes (DarkWake: Power Nap, maintenance, network). The screen stays off, so you don't notice, but programs run briefly. A Claude Code turn that was mid-stream notices the dropped stream and sends the request again, then the Mac sleeps 2–7 seconds later and that request is cut off too (StreamSuspended).

Each wake can re-send a context of hundreds of thousands of tokens, all night long. One report saw two background agents send 81 requests in 6.5 hours with only 29 completing (#102597); another saw a single Code tab session in the desktop app carry on with the lid shut (#103064). How much the aborted requests count against your limit is something only Anthropic can see.

Fixing it yourself

Check first: pmset -g log | grep -E "DarkWake|Clamshell" shows when the lid closed (Clamshell Sleep) and how often, and for how long, the Mac woke afterwards.

The key is to pick one state before you close the lid: fully awake or fully stopped. The in-between is the expensive part. Keep it awake to the end: with sudo pmset -a disablesleep 1 the Mac keeps running lid-closed and the stream isn't cut. Set it back with sudo pmset -a disablesleep 0 afterwards (it survives a restart, and if you forget, the Mac stays awake in your bag). Really stop it: press Esc to interrupt the turn before closing the lid, and make sure background agents have finished. With nothing to send, the wakes cost nothing.

Fewer wakes: sudo pmset -a powernap 0 cuts the longer Power Nap wakes, but short wakes for other reasons remain, so it reduces the retries rather than ending them.

With Lidnight

Lidnight uses Claude Code and Codex hooks to keep the Mac fully awake only while a turn runs (lid closed, on battery, background sessions included) and lets it sleep once every session has been quiet for 10 minutes. It doesn't sleep mid-work, so nothing gets cut off and re-sent between DarkWakes, and by the time it sleeps there's nothing left to send. The desktop app's Code tab uses the same ~/.claude hooks. Staying awake lid-closed is a Pro feature, included in the 7-day trial. Fixing "went to sleep mid-response"

Try Lidnight free

Apple Silicon Macs · macOS 13 or later. Every download includes a 7-day trial of everything in Pro, no payment details needed. Pro is a one-time payment (1 Mac $9.99 · 3 Macs $14.99, 50% off through Oct 31) with a 14-day refund.

Homebrew: brew install whereisdw/tap/lidnight