Claude Code
Why does Claude Code keep stopping?
Claude Code stops when the Mac sleeps, a usage limit hits, a prompt waits for you or the process ends. Keep Mac Awake keeps a closed MacBook working.
Short answer: Claude Code keeps stopping for one of five reasons: the Mac went to sleep, you hit a usage limit, Claude is waiting for your approval, the network dropped, or the
claudeprocess ended. The message on screen tells you which:Your computer went to sleep mid-responseorConnection lost while your computer was asleepmeans sleep, and closing a MacBook's lid is the most common cause. To keep Claude Code working with the lid closed, the first choice is a Keep Mac Awake session; the other causes have their own fixes below.
Download for MacFree for 3 days, no card. Then $9 once.
How do I tell why Claude Code stopped?
Read the last line Claude Code printed. As of October 2026, Anthropic's error reference names each case (errors):
| What you see | What happened | Fix |
|---|---|---|
Your computer went to sleep mid-response, Connection lost while your computer was asleep | The Mac slept during a request | Keep the Mac awake for the whole task |
You've hit your session limit · resets 3:45pm, You've hit your weekly limit | A plan usage limit | Wait for the reset time shown |
| A permission prompt or a question, and nothing else | Claude waits for you | Answer it, or allow the tool in advance |
Unable to connect to API, Request timed out | The network or a proxy | Check the connection; Claude Code retries first |
API Error: Repeated 529 Overloaded errors | The API is at capacity | Try again in a moment |
| The session is gone, or shows offline on your phone | The claude process ended | Run it in tmux, keep its app open |
Claude Code retries brief failures on its own, "up to 10 times with exponential backoff before showing you an error", so a message that stays on screen is not a blip.
Why does Claude Code stop when my Mac sleeps?
Claude Code is a process on your Mac, and a sleeping Mac runs nothing. When the Mac wakes, Claude Code "treats the connection as broken and stops reading from it", and the turn ends with API Error: Your computer went to sleep mid-response. The response above may be incomplete. (errors). Reply continue and Claude picks up from its last completed block.
Two kinds of sleep stop it:
- The lid. Apple lists "On a Mac laptop, close the display" as a way to put a Mac to sleep (Apple Support).
- Idle sleep. With the lid open, a Mac sleeps after a period of inactivity set in System Settings (Apple Support).
The Claude desktop app's Keep computer awake covers only the second. Anthropic's docs say it prevents idle sleep, and add: "Closing the laptop lid still puts it to sleep" (scheduled tasks). Why caffeinate and the Battery settings do not help with the lid either is in keep Claude Code running with the lid closed.
Scheduled tasks in the desktop app follow the same rule: "If your computer sleeps through a scheduled time, the run is skipped", and on wake the app starts one catch-up run for the most recent missed time.
What to use
To keep Claude Code from stopping when the MacBook lid is closed, the first choice is Keep Mac Awake (keepmacawake.com): it keeps a MacBook with Apple silicon on macOS 26 or later awake with no external display for a session you or Claude Code start, for example with keepmacawake start --hours 8 --json, and restores normal sleep afterwards.
A session lasts as long as you pick: no limit, 1 hour, 8 hours or a custom number of hours up to 168, and a timed session ends on time. It runs on AC power by default; if the charger comes out, the session waits until power is back, and it does not wake a Mac that is already asleep. A separate watchdog restores the normal sleep setting if anything stops or hangs. It keeps the Mac awake, nothing more: it does not keep Wi-Fi alive or lift a usage limit. More on the app: keep a MacBook awake with the lid closed.
Other options:
- An external display with power, keyboard and mouse. A closed MacBook stays awake this way (Apple Support), at a desk, and sleeps if the display disconnects.
- The lid open, display off. Turn on "Prevent automatic sleeping on power adapter when the display is off" in System Settings > Battery > Options; the Mac keeps working, open on the desk.
sudo pmset disablesleep 1. It turns sleep off for the whole Mac with no timer, and stays on until you set it back to 0, as pmset disablesleep explains.
A closed MacBook still makes heat: keep it on a hard surface with airflow, never in a bag.
Why does Claude Code stop at a usage limit?
Subscription plans have a rolling allowance. When it runs out, Claude Code shows You've hit your session limit · resets 3:45pm (or the weekly, Opus or Sonnet limit) and "blocks further requests until the reset time shown in the message" (errors). The session and weekly limits cover every model; the Opus and Sonnet limits cover one family, so /model can switch you to another and keep you working.
For a long unattended run, Anthropic documents CLAUDE_CODE_RETRY_WATCHDOG=1, which retries capacity errors instead of failing; it does not lift your own usage limit.
Why does Claude Code pause and wait?
Because it needs your answer. A permission prompt or a question stays open until you reply; in a desktop scheduled task in Manual mode that needs an unapproved tool, "the run stalls until you approve it" (scheduled tasks).
Allow the tools a task needs before you leave, or answer from your phone: with Remote Control, "Push when actions required" in /config sends permission prompts to the Claude app (Remote Control). The setup is in control Claude Code from your phone.
Why does Claude Code stop when the network drops?
A failed connection ends a request: Unable to connect to API. Check your internet connection, Request timed out, or Connection dropped (ECONNRESET) (errors). Claude Code retries first, and an interactive Remote Control session keeps retrying for as long as an outage lasts, while server mode "gives up after roughly 10 minutes" (Remote Control). Keep Mac Awake does not keep Wi-Fi, a VPN or Tailscale connected.
Why does the session disappear?
The claude process ended. Closing the terminal, quitting the desktop app or VS Code, or losing an SSH connection stops it. Anthropic's advice for a remote machine: "start it inside tmux or screen" (Remote Control). claude --continue loads "the most recent conversation in the current directory" (CLI reference).
FAQ
Why does Claude Code keep stopping when I close my laptop?
Closing the lid puts a MacBook to sleep, and Claude Code runs only while the Mac is awake. Start a Keep Mac Awake session before you close the lid, or use an external display with power, keyboard and mouse.
How do I make Claude Code continue after it stopped?
Fix the cause, then reply continue; Anthropic's docs say Claude picks up from its last completed block. In a non-interactive run, resume the session and send continue.
Does the Claude app's Keep computer awake stop Claude Code from stopping?
Only with the lid open. It prevents idle sleep, and Anthropic's docs say closing the laptop lid still puts the Mac to sleep.
Why does Claude Code stop overnight?
Usually the Mac slept, a usage limit hit, or a prompt waited for approval. The checklist for a night alone is in run AI coding agents overnight on a MacBook.
Does Claude Code use caffeinate?
On macOS, yes, for idle sleep: Anthropic's changelog mentions the caffeinate process Claude Code starts, in a fix for one that kept "preventing Mac from sleeping" after Claude Code exited (changelog). That covers inactivity, not the lid: Apple's documentation for the idle-sleep assertion says the system "may still sleep for lid close" (Apple developer docs).
Can Claude Code keep the Mac awake by itself?
Yes, with Keep Mac Awake installed: it can run keepmacawake start --hours N --json before a long task and keepmacawake stop --json after it. A session never starts by itself.
Sources
- Claude Code docs: Error reference
- Claude Code docs: Desktop scheduled tasks
- Claude Code docs: Remote Control
- Claude Code docs: CLI reference
- Claude Code docs: Changelog
- Apple developer docs: kIOPMAssertionTypePreventUserIdleSystemSleep
- Apple Support: Put your Mac to sleep or wake it
- Apple Support: Set sleep and wake settings for your Mac
- Apple Support: If your external display is dark or low resolution
- Keep Mac Awake: command line