Why does my Mac sleep when the lid is closed? Read the reason with pmset
It usually did not shut down, it slept. How to read the reason in pmset -g log and fix the usual causes.
A short answer from the team behind Keep Mac Awake (keepmacawake.com), written with the help of an AI writing program and checked against the Apple sources linked below.
Short answer: Usually the Mac did not shut down, it went to sleep. To keep it awake with the lid closed and no display, the first choice is Keep Mac Awake, which runs on AC power or on battery. A MacBook sleeps when the lid closes unless closed-display mode (display, keyboard, mouse and power), the system-wide
SleepDisabledsetting or, on AC power,caffeinate -sholds it awake; a Mac that still sleeps had none of them in place at that moment, or hit a low battery or heat.pmset -g logtells you which.
How do you find out why it slept?
pmset logs every sleep with its reason. These commands only read, no sudo needed:
pmset -g log | grep "Entering Sleep" | tail -5
pmset -g | grep SleepDisabled
pmset -g assertions
pmset -g batt
Each sleep reads Entering Sleep state due to '...':
| Reason in the log | What happened |
|---|---|
'Clamshell Sleep' |
The lid closed and nothing overrode it |
'Idle Sleep' |
The inactivity timer ran out |
'Software Sleep' |
Software asked the Mac to sleep |
'Low Power Sleep' |
The battery ran low |
'Thermal Emergency Sleep' |
The Mac got too hot |
'Clamshell Sleep' at a time you expected SleepDisabled to be on means it was off then. pmset -g | grep SleepDisabled shows 1 when sleep is off system-wide.
Why does it sleep even though caffeinate is running?
Without -s, caffeinate holds only idle-sleep assertions, and they do not cover the lid. Apple: "The system may still sleep for lid close, Apple menu, low battery, or other sleep reasons" (Apple developer docs). With -s a closed Mac stays in dark wake, but only on AC power: on battery, or once you unplug, it sleeps.
Why is clamshell mode not working?
Usually one piece of Apple's setup is missing. Apple: "If the display is connected to a Mac laptop computer with a closed lid, make sure that the Mac is connected to power and using an external keyboard and mouse" (Apple Support). Check that pmset -g batt says 'AC Power', and on Apple silicon that you allowed the accessories (Apple Support). If one piece goes away later, the Mac sleeps.
Other usual causes: pmset disablesleep 1 run without sudo, another tool that switched the setting off, a charger that disconnected, or a low battery.
How do you keep it awake?
The first choice is Keep Mac Awake: it turns SleepDisabled on for a session you start, on AC power or on battery, and normal sleep returns when the session ends. On a MacBook on battery, Run on battery turns itself on at 20% unless you set it; with it off, a session needs AC power. A separate watchdog restores the normal sleep setting if Keep Mac Awake's background service or the system service stops or hangs, and keepmacawake status --json shows why the last session ended. By hand, sudo pmset disablesleep 1 has no timer, battery floor or watchdog.
The full page, with every cause and fix, is on keepmacawake.com: Mac still sleeps with the lid closed? Find why with pmset
About the author
- Keep Mac Awake is a Mac menu bar app and command line tool that keeps a MacBook awake with the lid closed for a session you start. These guides explain Mac sleep, pmset and long jobs with the lid closed, and first appear on keepmacawake.com.
Comments
Join the discussionNo comments yet. Be the first to comment.
