How to Keep Your Mac Awake: Settings, caffeinate, the Lid
Stop a Mac from sleeping with one setting in System Settings or the caffeinate command in Terminal. Display sleep vs. system sleep, and what a closed lid does.

For good, change System Settings: Lock Screen for the display, Battery → Options… for the Mac itself. For a single task, run caffeinate in Terminal. Neither survives a closed lid unless an external display is connected.
A big download ran for an hour and then stopped. The screen went dark in the
middle of a presentation. The build you left overnight is still halfway done
in the morning. In all three cases the Mac simply went to sleep on a timer:
nobody touched it for a while, so it decided it wasn’t needed. You can
change that for good in System Settings, or work around it for one task —
for example, with the caffeinate command in Terminal.
First decide what must stay awake — the display or the Mac itself.
The answer tells you which setting to touch.
Display off vs. Mac asleep
These are two different things. When you’re idle, macOS turns the display off first, and the computer itself goes to sleep separately, by its own rules. The screen can be black while the Mac keeps downloading, building and copying: the display sleeps, the system doesn’t.
- You need the screen — a presentation, a video, a dashboard you glance at from across the room. Keep the display awake.
- You need the work — a download, a backup, a long calculation. Let the screen go dark; keep the system awake.
That’s also the classic mistake: people set the display to Never when all they wanted was a download that doesn’t break — and the laptop lights an empty screen all day.
Built in: for good or for a long while
When the display turns off. System Settings → Lock Screen. On a laptop there are two options: “Turn display off on battery when inactive” and “Turn display off on power adapter when inactive”. On a desktop Mac there’s one: “Turn display off when inactive”. Pick a longer time, or Never.
When the Mac itself sleeps. On a laptop: System Settings → Battery → the Options… button → “Prevent automatic sleeping on power adapter when the display is off”. On a desktop Mac the same option is in Energy and is called “Prevent automatic sleeping when the display is off”.
Note that on a laptop this works only on the power adapter. There’s no built-in setting to stay awake on battery with the display off — and that’s sensible.
The one downside of the built-in route: it’s easy to forget to switch back. For one-off jobs, the temporary options are handier.
For one task: caffeinate
macOS has a built-in command called caffeinate. Open Terminal
(Applications → Utilities) and type:
caffeinate— the Mac won’t idle-sleep while the command runs; stop it with ⌃C or by closing the window;caffeinate -d— keep the display on too;caffeinate -i <command>— stay awake while a command runs, for examplecaffeinate -i rsync …; when the command ends, the Mac sleeps normally again;caffeinate -t 3600— for an hour (the time is in seconds);caffeinate -w <PID>— while the process with that number is alive; you’ll find the number in Activity Monitor’s PID column;caffeinate -s— no system sleep at all, but only on AC power.
Flags combine: caffeinate -d -t 5400 gives you an hour and a half with
the screen on — about right for a talk.
The closed lid
Here’s the honest answer: neither caffeinate -i nor apps that keep the
Mac from idle sleep survive a closed lid. That’s by design: Apple’s
developer documentation says plainly that even with this hold in place
the Mac may still sleep when the lid closes, when you choose Sleep from
the Apple menu, or when the battery is low.
You can work with the laptop closed if an external display is connected: the Mac carries on using it. For that you need power and an external keyboard with a mouse or trackpad — that’s how Apple describes it too, for example in its article on two displays with an M3 MacBook. Power can come from the adapter or from a display that charges the Mac.
You’ll find pmset commands online that supposedly disable sleep with
the lid closed. We don’t give one here: on macOS 27 the key isn’t even
in the man pmset manual, and a laptop that stays awake when closed is
easy to put in a bag still running. It has no air in there — it heats up
and drains to zero.
The opposite problem: the Mac won’t sleep
Sometimes it’s the other way round: you left the Mac, it stayed awake all night, and the battery is empty. Something is holding it. In Terminal:
pmset -g assertions
Under “Listed by owning process” you’ll see who is holding the Mac and
why: PreventUserIdleSystemSleep keeps the system awake,
PreventUserIdleDisplaySleep keeps the display on. Some apps show a
different type, such as NoIdleSleepAssertion — same idea. The short
version is the sleep line in pmset -g: after “sleep prevented by”,
in parentheses, are the apps responsible.
Without Terminal: Activity Monitor → Energy tab → the Preventing Sleep column. “Yes” means that app is keeping the Mac awake. The rest of the tabs are covered in the guide to Activity Monitor.
Usual suspects: video or music playing in the background, a browser tab
with a call, downloads and syncing, file or screen sharing, and a
caffeinate forgotten in another Terminal tab.
What not to do
- Don’t put the laptop in a bag while something keeps it awake. A closed lid will usually put it to sleep, but if it doesn’t, it will overheat.
- Don’t set Never on battery “just this once”: such settings get forgotten, and the charge drains.
- Don’t install third-party tools with administrator rights for a single
download: the built-in
caffeinateis enough.
In the app
In Mac Resources, keeping the Mac awake lives in the menu of its menu bar item: Prevent sleep. Below it:
- Display — May turn off (for downloads and builds) or Keep on (for
presentations). It’s the same mechanism as
caffeinate -iandcaffeinate -d; - Duration — 15 minutes, 1, 2, 4 or 8 hours, or Until I turn it off. When time is up, the Mac sleeps normally again;
- Turn off when battery is below 20% — on battery, the hold is released automatically and the Mac sleeps normally again instead of draining to zero.
Under the toggle you see the state: Off, On until 18:30, or On until you
turn it off. While it’s on, a lock shows in the menu bar item. In
pmset -g assertions it’s labeled “Resources Mac: keep awake”.
The toggle doesn’t survive a restart of the app or the Mac, so a hold
never lingers unnoticed. The display mode, duration and battery
checkbox are remembered. And, just like caffeinate, it doesn’t beat a
closed lid: that requires administrator rights, which a sandboxed app
doesn’t get. Where the item sits and how to move it is in the guide to
the menu bar.
If the Mac stays awake but runs hot and slow, go through the step-by-step diagnosis. And if it’s slow after a macOS update, a night without sleep may be exactly what it needs — see the guide on a Mac slow after an update.