Can a MacBook stay awake with the lid closed?
Only in closed-display mode. A MacBook keeps running with the lid closed when it’s connected to power and to an external display, keyboard and mouse; that’s the setup Apple describes. Otherwise closing the lid puts it to sleep, and the usual way apps keep a Mac awake doesn’t change that: Apple’s power-management header says a Mac held awake this way “may still sleep for lid close”. SleepPilot doesn’t keep a closed MacBook awake either. To keep working without an external display, leave the lid open and let the screen turn off.
Updated · commands checked on macOS 27.2
Closed-display mode
Closed-display mode is the name Apple has used for running a Mac laptop with the lid closed and an external display. Apple’s support pages describe what it needs: power, an external keyboard and mouse, and on Apple silicon laptops, permission for the display, mouse and keyboard to connect.
- Connect the MacBook to its power adapter. Apple says a Mac laptop used with the lid closed should be connected to power.
- Connect an external display, keyboard and mouse or trackpad. If the display doesn’t come on through a hub or dock, connect it to a port on the Mac itself.
- On a Mac laptop with Apple silicon, allow the display, mouse and keyboard when macOS asks, while the lid is still open. The setting is in System Settings › Privacy & Security › Accessories › Allow accessories to connect.
- Close the lid. The Mac keeps running and uses the external display.
Apple says that once these are allowed, you can use the Mac with the lid closed, including in a docking station, and approve other accessories without opening the lid.
What keep-awake apps can and can’t do
Apps and commands that keep a Mac awake, including caffeinate -i and SleepPilot, hold a power assertion that blocks idle sleep: the sleep that happens when nobody touches the Mac for a while. Apple’s power-management header is explicit that this doesn’t cover everything: the Mac may still sleep for lid close, the Apple menu, low battery or other reasons.
You can see it in the power log. This is what closing the lid did on our MacBook Pro, on battery:
pmset -g log | grep "Clamshell Sleep"
2026-11-11 13:55:57 +0200 Sleep Entering Sleep state due to 'Clamshell Sleep':TCPKeepAlive=active Using Batt (Charge:100%) 162 secs
caffeinate -s asks for more: its man page says it prevents the system from sleeping, valid only on AC power. The man page says nothing about the lid, and Apple doesn’t describe it as a way to keep a closed MacBook awake, so don’t rely on it with the Mac in a bag.
Without an external display
If you just want a long job to finish, leave the lid open and let the display turn off. caffeinate -i keeps the Mac awake with the screen dark; so does SleepPilot with Keep the display on turned off. Both end on their own: caffeinate when the time or the command is up, SleepPilot after the time you chose or when the command, download or backup it’s waiting for finishes.
The heat risk
Don’t keep a MacBook awake in a bag or under a pillow. Apple’s safety information says a MacBook and its power adapter can become very warm in normal use, to always allow adequate ventilation, and not to place them under a blanket, pillow or your body.
Closed-display mode is meant for a Mac on a desk with air around it. SleepPilot also lets the Mac go back to its normal sleep if it reaches critical overheating, but that’s a safety net, not a reason to pack an awake Mac away.
Questions
Does closed-display mode work on battery?
Apple’s instructions say to make sure the Mac is connected to power when it’s used with the lid closed. Plan on keeping it plugged in.
Does caffeinate -s keep a MacBook awake with the lid closed?
Not as far as Apple documents. The man page says -s prevents system sleep and works only on AC power; it doesn’t mention the lid. Apple’s only documented way to use a closed Mac laptop is closed-display mode.
Can I close the lid while a download or an AI agent runs?
Only in closed-display mode. Otherwise leave the lid open and let the screen turn off: caffeinate -i or SleepPilot keep the Mac awake with the display dark. Until a command finishes.
Does SleepPilot have a lid-closed mode?
No. With SleepPilot running, closing the lid still puts a MacBook to sleep unless it’s in closed-display mode.
What does “Clamshell Sleep” mean in the power log?
That the Mac went to sleep because the lid was closed.
Sources
- If your external display is dark or low resolution — Apple Support
- Allow USB and other accessories to connect to your Mac — Apple Support
- Important safety information for your Mac (MacBook Pro) — Apple Support
- IOPMLib.h: power assertion types — Apple open source
- caffeinate(8) man page