SettingsHow-to
How to keep a MacBook awake with the lid closed (clamshell mode)
Short answer
A MacBook stays awake with the lid closed only in clamshell mode: it needs the charger, an external display, and an external keyboard or mouse. Connect all three, then close the lid, and the Mac keeps working on the external screen. Without an external display, closing the lid puts the Mac to sleep, and caffeinate and most keep-awake apps can't change that. Only a system setting can, either from Terminal or from an app that turns it on for you.
On this page
Use clamshell mode
- Connect the charger.
- Connect an external display and check that it shows your desktop.
- Connect a keyboard and a mouse or trackpad, by USB or Bluetooth.
- Close the lid. The external display may go dark for a moment, then everything moves onto it.
To wake the Mac later, press a key or click the mouse. If the windows land on the wrong screen when you open the lid again, see choosing the main display.
The Mac still sleeps in clamshell mode
- Check the charger. Clamshell mode needs power; on battery, a closed MacBook sleeps.
- Check the display connection. If the monitor or a dock drops the signal, the Mac thinks it has no screen and goes to sleep. External monitor problems covers the usual causes.
- Keep it awake while the external display is off. Open System Settings › Battery › Options and turn on Prevent automatic sleeping on power adapter when the display is off.
Why most keep-awake apps can't override the lid
The caffeinate command and simple keep-awake apps only stop the Mac from falling asleep when it's idle. Closing the lid is a direct request to sleep, like choosing Sleep from the Apple menu, so macOS sleeps anyway. To stay awake with the lid closed, an app has to switch on the system setting below, which needs your administrator approval once. Cruise Control does this for you, and turns it back off when it stops.
Without an external display: the system setting
There is a system setting that turns sleep off completely, including when you close the lid. Use it only for a specific job, such as a long upload with the Mac on a desk, and turn it back off afterwards.
- Open Terminal and run
sudo pmset -a disablesleep 1. Enter your Mac's password when asked. - Close the lid. The Mac keeps running.
- When you're done, run
sudo pmset -a disablesleep 0to turn normal sleep back on.
With this setting on, the Mac doesn't sleep in a bag either. It can get hot and drain the battery quickly. Don't forget to turn it off.
Sources and further reading
- pmset man page · SS64
Applies tomacOS 27TahoeSequoiaSonoma
Reader tips
No tips yet. If something else worked for you, or a step looks different on your Mac, add it here.