If your MacBook sleeps although a keep-awake setting is on, a common cause is the lid. Keep-awake settings, caffeinate and most apps only prevent sleep from inactivity, and closing the lid puts a MacBook without an external display to sleep regardless.
If the lid was open, the cause is usually one of four things: the setting only applies on the power adapter, the keep-awake tool is no longer running, the battery ran empty, or the Mac never slept and the task stopped for another reason.
What are the causes, in order?
- The lid was closed.
- The keep-awake setting only applies on the power adapter and the MacBook was on battery.
- The keep-awake tool had ended: the Terminal window was closed or the app session ran out.
- The battery was empty.
- The Mac was awake, but the display was off or the screen was locked.
- The Mac was awake, but the task was waiting for you or lost its connection.
Go through them from the top. Change one thing at a time so you can tell what helped.
1. Was the lid closed?
Closing the lid always triggers sleep on a MacBook without an external display. No normal setting prevents that. caffeinate prevents idle sleep, not lid-close sleep, and the same goes for the keep-awake options built into most programs.
If your task stops at the moment you close the lid, this is the cause. These are the ways around it:
- Keep the lid from closing. A lid spacer such as WakeClip, a clip that holds the MacBook lid open, stops the lid mechanically.
- Amphetamine or a similar app with an option for the closed lid. The lid is then fully shut.
-
sudo pmset -a disablesleep 1. Switches sleep off system-wide. Needs admin rights and must be reset withdisablesleep 0. - External display or HDMI dummy plug. The setup with a display, power adapter, keyboard and mouse is the one Apple intends.
- Cloud or a second computer. The task does not run on the MacBook.
The guide Keep a MacBook running with the lid closed shows which way fits which situation, and Keep a MacBook awake with the lid closed: 7 ways compared puts them all in one table.
2. Was the MacBook on battery?
The macOS option under System Settings, Battery, Options prevents automatic sleep on the power adapter while the display is off. As its name says, it applies on the power adapter. On battery it does nothing.
If the problem only appears when the MacBook is unplugged, plug it in for long tasks, or cover idle sleep with caffeinate -i, which is not tied to that setting.
3. Was the keep-awake tool still running?
caffeinate works only as long as the command runs. If you close the Terminal window or the command ends, normal sleep returns. Started as caffeinate -i yourcommand, it ends together with that command.
Apps such as Amphetamine work in sessions. Check whether a session was active and whether it had a time limit that ran out.
You can see what currently keeps the Mac awake with pmset -g assertions in the Terminal. If nothing is listed that prevents idle sleep, nothing is holding it off.
4. Was the battery empty?
An empty battery ends every task, whatever the settings. Note the charge when you start and when you come back. For anything long, use the power adapter.
5. Was it really sleep, or only the display?
A dark display, a locked screen and a sleeping Mac look alike from outside. They are different states. The display switches off according to the display setting of your Mac, and a task continues with the display off as long as the Mac is awake.
Check the task, not the screen. Is the output file still growing, is there a new log line, is the transfer further along than before? If work continued while the screen was dark, the Mac did not sleep.
6. Did the task stop for another reason?
An awake Mac does not guarantee a progressing task. The common reasons are:
- A waiting prompt. The program asks for a permission, a sign-in or an answer.
- Network. If you carry the MacBook out of Wi-Fi range, it loses the connection. That can interrupt a task whether the Mac is awake or not.
- An error or a finished run. Read the last message and note the time.
A simple test separates these from sleep: run a small task with the lid open and watch it. If it also stops there, the lid and the sleep settings are not the cause.
What if you use WakeClip and the task still stops?
WakeClip keeps the lid 12 mm open. Your MacBook does not go to sleep from closing the lid, and whatever is running keeps running.
That covers cause 1. Causes 2 to 6 are not solved by a clip. Idle sleep is still handled by your settings or the running program, so check points 2 and 3 first.
Also check the fit. The clip belongs on the front edge of the case, to the left of the trackpad, in the version made for your MacBook model. Do not push it on with force, do not press the lid down, and do not put anything on the lid.
Where to go from here
For specific tools, see Claude Code stops when you close your MacBook and Codex stops when the MacBook lid is closed.
If cause 1 was yours and you want to lower the lid without changing the system, look at the WakeClip lid spacer for your MacBook model. It needs no installation and no admin rights, and there is nothing to reset afterwards.
