How to Keep Mac From Sleeping: Settings, Terminal and Apps
Keep a Mac awake by raising the display-off time in System Settings, running caffeinate in Terminal, or clicking KeepingYouAwake in the menu bar.
By the TopMac team · November 30, 2026 · 6 min read
To keep a Mac from sleeping, open System Settings, click Lock Screen, and choose a longer time for the two "Turn display off" menus. On a laptop, also open Battery, click Options, and turn on "Prevent automatic sleeping on power adapter when the display is off". For a temporary fix, type caffeinate in Terminal, or use a menu bar app such as KeepingYouAwake.
Change the sleep settings in System Settings
macOS splits sleep settings across two places: one for how long the display stays on, and one for whether the Mac itself sleeps once the display is off.
Set how long the display stays on
- Choose Apple menu > System Settings.
- Click Lock Screen in the sidebar. You may need to scroll down to find it.
- Click the pop-up menu next to "Turn display off on battery when inactive" and choose a longer time.
- Do the same for "Turn display off on power adapter when inactive".
Apple notes that some of these options are not available on every Mac.
The same pane has "Require password after screen saver begins or display is turned off". That controls locking, not sleeping, so you can leave it as it is.
Stop a MacBook sleeping when the display is off
- Choose Apple menu > System Settings.
- Click Battery in the sidebar.
- Click Options.
- Turn on "Prevent automatic sleeping on power adapter when the display is off".
As the name says, this only applies while the laptop is plugged in. With it on, the screen can still go dark after the time you set in Lock Screen, but the Mac keeps working behind it. That suits an overnight backup or a long upload.
Stop a desktop Mac sleeping when the display is off
- Choose Apple menu > System Settings.
- Click Energy in the sidebar.
- Turn on "Prevent automatic sleeping when the display is off".
Apple's own guidance is worth repeating: delaying or preventing sleep can increase power use. On a laptop running on battery, that means a shorter time between charges.
Use caffeinate in Terminal
Every Mac ships with a command line tool called caffeinate that holds off sleep for as long as it runs. Nothing needs to be installed, and the Mac goes back to its normal behaviour as soon as the command ends.
- Open Terminal from the Utilities folder inside Applications.
- Type
caffeinateand press Return. - Leave the window open. The Mac will not go to sleep from inactivity while the command is running.
- Press Control-C to stop it.
Run with no options, caffeinate only prevents idle sleep. The display can still turn off. Flags change what it holds awake.
| Flag | What it does |
|---|---|
-d | Keeps the display from sleeping |
-i | Keeps the system from idle sleeping |
-m | Keeps the disk from idle sleeping |
-s | Keeps the system from sleeping, but only while on AC power |
-u | Declares that the user is active, which turns the display on if it is off |
-t | Sets a timeout in seconds, after which the command stops holding the Mac awake |
-w | Waits for the process with a given ID to exit, then stops |
Flags can be combined. A few examples that cover most needs:
caffeinate -dkeeps the screen on until you press Control-C. Useful for a presentation.caffeinate -t 3600holds off idle sleep for one hour and then exits by itself.caffeinate -i ./backup.shruns a script and keeps the Mac awake until that script finishes. Put any command after the flags andcaffeinatestays active for exactly as long as that command runs.caffeinate -w 4321stays active until the process with ID 4321 exits. You can find a process ID in Activity Monitor.
Two details from the manual page are easy to miss. The -t timeout is ignored when you give caffeinate a command to run, because the command's own duration is used instead. And -u by itself only lasts five seconds unless you add -t. Type man caffeinate to read the full manual.
Use KeepingYouAwake from the menu bar
If you would prefer not to open Terminal each time, KeepingYouAwake puts the same thing behind an icon in the menu bar. It is a small wrapper around caffeinate, so it relies on Apple's own tool instead of a custom mechanism.
Click the icon to turn it on. It stays active until you click again, or for one of several preset durations. It can also switch itself off when the battery gets low.
It costs nothing, the code is MIT licensed, and there is very little to configure. You can download it from the developer's site or install it with Homebrew using brew install --cask keepingyouawake.
It suits jobs that come up now and then: a long download, a render, or a presentation where you do not touch the keyboard for a while.
What happens when you close the lid
Closing the lid of a MacBook puts it to sleep, and none of the methods above are designed to change that. They deal with sleep caused by inactivity.
KeepingYouAwake's developer is direct about this. The app's documentation says it does not work on a MacBook with a closed lid, and that it only prevents sleep on desktop Macs and on laptops with the lid open, because of macOS limits and for thermal reasons. The caffeinate manual page lists no option for the lid either.
The supported way to use a MacBook with the lid shut is with an external display. Apple's guidance for that setup is to have the Mac connected to power and to use an external keyboard and mouse.
Without an external display, leave the lid open and let only the screen turn off, using the Battery option described earlier.
Which method to use
- You always want a longer delay. Change the Lock Screen menus once and forget about it.
- You run long jobs while plugged in. Turn on the Battery or Energy option so the Mac stays awake with the display off.
- You need it for one task. Run
caffeinatein front of the command, or with-tfor a set time. - You need it often but not always. A menu bar toggle is quicker than either of the above and is harder to forget, since the icon shows whether it is on.
The built-in settings are enough for most people.
Frequently asked questions
Does caffeinate keep a MacBook awake with the lid closed?
Its manual page has no lid option, and KeepingYouAwake, which is built on it, states that it does not work with the lid closed. To work with the lid shut, connect power, an external display, a keyboard and a mouse.
How do I stop my Mac screen from turning off?
Go to System Settings > Lock Screen and pick a longer time in the two "Turn display off" menus. For a temporary version, run caffeinate -d in Terminal and press Control-C when you are done.
Is it bad to stop a Mac from sleeping?
Apple notes that delaying or preventing sleep can use more power. On battery that means less running time, so a timer or a low battery cut-off is a sensible precaution.
Why does my Mac not sleep when I expect it to?
Apple lists several causes, including people using shared services on your Mac, Spotlight indexing a disk, apps that are reading from a disk, and faulty connected devices. Activity Monitor can show whether a background process is busy.