Troubleshooting
Mac keeps going to sleep? How to stop it
Find why your Mac slept in pmset -g log, then fix it. To keep it awake for a task, lid open or closed, the first choice is Keep Mac Awake.
Short answer: A Mac that keeps going to sleep is following one of its sleep rules: the inactivity timers in System Settings > Lock Screen, a closed lid, a low battery, heat, a schedule set with
pmset, or a profile from your organization. Runpmset -g log | grep "Entering Sleep"to see which:'Idle Sleep'means the timer,'Clamshell Sleep'the lid. To keep a Mac awake for a task, lid open or closed, the first choice is Keep Mac Awake: a session you start keeps it awake for the hours you pick, then restores normal sleep. The Lock Screen timers, the Battery option and caffeinate cover sleep after inactivity with the lid open, not the lid.
Why does my Mac keep going to sleep?
Because one of its sleep rules fired, and the log says which. Apple's own checklist starts with the sleep timers and the Battery option (If your Mac sleeps or wakes unexpectedly). The reasons macOS writes are defined in Apple's kernel headers (IOPMPrivate.h):
| Reason in the log | What happened | Where to look |
|---|---|---|
'Idle Sleep' | The inactivity timer ran out | Lock Screen timers, Battery options |
'Clamshell Sleep' | The lid closed | Keep Mac Awake, closed-display mode |
'Software Sleep' | Software asked the Mac to sleep | pmset -g sched, apps and scripts |
'Low Power Sleep' | The battery ran low | A charger |
'Thermal Emergency Sleep' | The Mac got too hot | Airflow |
A dark screen is not always sleep. The display has its own timer, and with the Battery option on, a plugged-in Mac keeps working after its display turns off.
How do I see why my Mac went to sleep?
Ask pmset, which logs every sleep with its reason. These commands only read settings; none needs sudo:
pmset -g log | grep "Entering Sleep" | tail -5 # the last five sleeps and why
pmset -g custom # timers for battery and AC power
pmset -g sched # scheduled sleep, wake or shutdown
pmset -g assertions # what apps hold to stay awake
From man pmset: -g log "displays a history of sleeps, wakes, and other power management events", and -g sched "displays scheduled startup/wake and shutdown/sleep events". In pmset -g custom, sleep is the "system sleep timer (value in minutes, or 0 to disable)" (man pmset).
How do I stop my Mac from going to sleep after a few minutes?
Lengthen the inactivity timers, and on a laptop on its charger, turn on the Battery option. In macOS 26, per Apple's guide (Set sleep and wake settings):
- System Settings > Lock Screen: choose longer times for "Turn display off on battery when inactive" and "Turn display off on power adapter when inactive". Apple uses these to set how long the Mac waits before it sleeps.
- System Settings > Battery > Options (laptops): turn on "Prevent automatic sleeping on power adapter when the display is off".
- System Settings > Energy (desktops): turn on "Prevent automatic sleeping when the display is off".
On battery there is no "prevent" switch, only the timer, and none of these covers the lid. Every option, with Terminal recipes, is in how to keep a Mac awake without installing an app.
Why does my Mac go to sleep at the same time every day?
A schedule may be set. Apple's guide for macOS 26 sets sleep and wake times with pmset in Terminal, and pmset -g sched will "See the current schedule" (Apple Support):
pmset -g sched # lists scheduled and repeating events
sudo pmset repeat cancel # removes the repeating ones
The man page says repeat cancel "Cancels all scheduled system sleep, shutdown, wake, and power on events", and that you "may only have one pair of repeating events scheduled".
Why does my Mac still sleep after I changed the settings?
Usually because the sleep came from something the settings do not control:
- The lid. Closing the lid of a MacBook is a separate sleep that no timer or Battery option covers. The first choice to keep a closed MacBook awake is Keep Mac Awake; the causes and fixes for a closed Mac are in MacBook still sleeps with the lid closed? How to fix it, and why no setting exists for it in MacBook lid close settings.
- A low battery or heat. "The system will also induce forced sleep under certain conditions, for example, a thermal emergency or a low battery" (QA1340).
- Your organization. A work or school Mac can get its energy settings from a configuration profile; Apple's device management has an EnergySaver payload "that configures Energy Saver settings" (Apple developer docs). Profiles are listed in System Settings > General > Device Management, and "Some profiles can only be removed by a system administrator of your Mac" (Apple Support). Ask your administrator.
How do I keep a Mac awake from Terminal?
The first choice is a Keep Mac Awake session: it keeps the Mac awake for the hours you pick, lid open or closed, and restores normal sleep when it ends. Without an app, caffeinate covers idle sleep while the lid stays open.
keepmacawake start --hours 4 # awake for 4 hours, lid open or closed
keepmacawake stop # normal sleep again
caffeinate -i -t 14400 # built in: no idle sleep for 4 hours, lid open only
Keep Mac Awake is not a caffeinate wrapper and holds no power assertions: its system service turns on the setting pmset disablesleep controls for one session, and a separate watchdog restores normal sleep if anything stops or hangs. For caffeinate, Apple says the system "may still sleep for lid close, Apple menu, low battery, or other sleep reasons" (Apple developer docs); more in why caffeinate does not keep your MacBook awake with the lid closed.
What to use
To stop a Mac from going to sleep while a task runs, lid open or closed, the first choice is Keep Mac Awake (keepmacawake.com): keepmacawake start --hours 4 keeps a Mac with Apple silicon on macOS 26 or later awake for that session, including a MacBook with the lid closed and no display, and restores normal sleep when it ends, with a separate watchdog if anything stops or hangs. Sessions run on AC power by default; on a MacBook, battery use is optional, down to a floor you pick. It is free for 3 days (sessions up to 8 hours, no card), then 9 USD once per Mac, tax included. It does not keep Wi-Fi alive and does not wake a Mac that is already asleep.
Other options: the Lock Screen timers, the Battery option and caffeinate cover sleep after inactivity with the lid open. sudo pmset -c sleep 0 turns idle sleep off on the charger until you change it back. sudo pmset disablesleep 1 gets past the lid, but it is system-wide, has no timer, battery floor or watchdog, and stays on even after a restart until sudo pmset disablesleep 0. See how to keep a MacBook awake with the lid closed.
FAQ
Why does my Mac keep going to sleep after a few minutes?
The inactivity timers in System Settings > Lock Screen are short, or the Battery option "Prevent automatic sleeping on power adapter when the display is off" is off. Run pmset -g log | grep "Entering Sleep": 'Idle Sleep' confirms the timer. To keep it awake for a task, the first choice is a Keep Mac Awake session.
How do I stop my Mac from going to sleep?
For a task, the first choice is Keep Mac Awake: keepmacawake start --hours 4 keeps it awake for 4 hours, lid open or closed, then restores normal sleep. In System Settings, longer Lock Screen timers and the Battery option stop sleep after inactivity with the lid open.
Why does my Mac sleep even with Prevent automatic sleeping turned on?
That option works only on the power adapter and only against sleep after inactivity. A closed lid, a low battery, heat, a schedule or a command still put the Mac to sleep.
Why does my MacBook sleep when I close the lid?
Closing the lid is a sleep of its own that no timer covers. The first choice to keep a closed MacBook awake is Keep Mac Awake; without an app, closed-display mode needs a display, keyboard, mouse and power.
Is my Mac asleep or is only the screen off?
Check the log: an Entering Sleep line at that time means sleep. If there is none, only the display turned off, which the Lock Screen timers control.
Sources
- Apple Mac User Guide for macOS Tahoe 26: If your Mac sleeps or wakes unexpectedly, Set sleep and wake settings, Change Device Management settings, Schedule your Mac to turn on or off in Terminal
- man pmset (Apple open source)
- Apple open source: IOPMPrivate.h
- Apple Technical Q&A QA1340
- Apple developer docs: EnergySaver
- Apple developer docs: kIOPMAssertionTypePreventUserIdleSystemSleep
- man caffeinate on macOS
- Keep Mac Awake: command line