Skip to content
86% off$349 $48.86code BF2026

Guides

How to Stop Your Mac From Going to Sleep

Prevent your Mac from sleeping with System Settings, caffeinate or an app. Steps for MacBooks and desktops on macOS 14 and later, and what the lid does.

GuideUpdated 10 min read

On this page

To prevent your Mac from sleeping on its own, open System Settings and turn on the "prevent automatic sleeping" option. On a MacBook it's under Battery ▸ Options…, and on a desktop it's under Energy. That keeps the Mac awake while the screen turns off. If the screen should stay on too, set the display timeout in Lock Screen to Never.

For a temporary fix, open Terminal and run caffeinate -d, then press ⌃C (Control-C) when you're done. Nothing changes permanently.

None of these methods stop sleep when you close the lid or choose Sleep yourself. That's covered further down.

What makes a Mac go to sleep

Two kinds of idle sleep matter here:

  • Display sleep. After the inactivity time set in Lock Screen, macOS turns the screen off. The Mac keeps working with the screen dark.
  • Idle system sleep. If you haven't touched the keyboard or trackpad for a while and no app has asked macOS to stay awake, the whole Mac sleeps. Downloads pause, network connections drop and scripts stop.

Apps ask macOS to stay awake through power assertions. A video player keeping the screen on during a film is one example. Every method on this page either changes the idle timers or holds one of these assertions.

Some sleep has nothing to do with idle timers. Closing a MacBook's lid, choosing Sleep from the Apple menu, a nearly empty battery and a sleep schedule set with pmset all put the Mac to sleep regardless.

Prevent your Mac from sleeping in System Settings

This is the built-in, permanent method. Use it for a Mac that should never idle-sleep while plugged in. The steps apply to macOS 14 Sonoma, macOS 15 Sequoia and macOS 26 Tahoe. If a label doesn't match on your Mac, type the quoted words into the search field at the top of the System Settings sidebar.

On a MacBook

  1. Open System Settings from the Apple menu.
  2. Click Battery in the sidebar.
  3. Click Options….
  4. Turn on Prevent automatic sleeping on power adapter when the display is off.
  5. Click Done.

The Mac now stays awake while it's plugged in, even after the screen turns off. Battery settings have no matching switch for running on battery. For that, use caffeinate or an app (see below).

To keep the screen on as well:

  1. In System Settings, click Lock Screen.
  2. Set Turn display off on power adapter when inactive to Never, or to a longer time.
  3. If you want, set Turn display off on battery when inactive to a longer time. The battery will drain faster.

On an iMac, Mac mini, Mac Studio or Mac Pro

  1. Open System Settings.
  2. Click Energy in the sidebar. On some versions it's called Energy Saver, so searching for "Energy" finds it either way.
  3. Turn on Prevent automatic sleeping when the display is off.
  4. To keep the screen on too, click Lock Screen and set Turn display off when inactive to Never.

What this method can't do

  • It has no timer. The Mac stays awake until you change the setting back.
  • On a MacBook it only works on the power adapter.
  • If the screen never turns off, it won't lock when it would otherwise turn off. That matters on a shared or office Mac. Check Start Screen Saver when inactive and Require password after screen saver begins or display is turned off in Lock Screen if you want the screen to lock while the Mac keeps working.

Every sleep-related setting is explained in Mac sleep settings explained.

Keep a Mac awake from Terminal with caffeinate

caffeinate is built into macOS. It holds a power assertion while it runs and releases it when it stops. It doesn't change any settings, so there's nothing to undo. Terminal is in Applications ▸ Utilities.

Keep the Mac and the display awake until you stop it:

bash
caffeinate -d

-d prevents display sleep, which also keeps the Mac awake. Press ⌃C in that Terminal window to stop.

Keep the Mac awake but let the screen turn off. This is the one for downloads and renders:

bash
caffeinate -i

-i prevents idle system sleep only. Press ⌃C to stop.

Keep it awake for a set time, given in seconds (3600 is one hour):

bash
caffeinate -i -t 3600

It ends by itself when the time is up, and normal sleep returns.

Keep it awake until a running process exits. Find the process ID in Activity Monitor's PID column and use it in place of 1234:

bash
caffeinate -i -w 1234

Keep it awake while one command runs by putting the command after the flags:

bash
caffeinate -i ./backup.sh

The assertion ends when the script finishes.

Things to know about caffeinate:

  • Closing the Terminal window or quitting Terminal stops it. Leave the window open, or minimize it.
  • Nothing on screen shows it's running except that Terminal window.
  • To see what is keeping your Mac awake right now, caffeinate included, run pmset -g assertions. It only reads information and changes nothing.

Every flag, with more examples, is in our caffeinate command guide.

Keep it awake for a set time, then sleep normally

The built-in options:

  • caffeinate -t <seconds>, shown above. You have to convert hours to seconds and keep the window open, and it can't stop at a clock time.
  • Change System Settings and remember to change it back. If you forget, the Mac stays awake overnight.

A menu bar app takes fewer steps. We make Glowmoth, a menu bar app that keeps the Mac awake for a set time, until a clock time, or while something is running. It needs macOS 14 or later. To start a timed session:

  1. Right-click the Glowmoth icon (a moth and a lamp) in the menu bar.
  2. Under Keep This Mac Awake, pick a duration. The defaults are 15 Minutes, 30 Minutes, 1 Hour, 2 Hours, 4 Hours and 8 Hours, plus Indefinitely.
  3. To stop at a clock time instead, open Until and pick the next 18:00 or 7:00, or choose Other Time… for any other time. The labels follow your 12- or 24-hour clock setting.
  4. For any other length, choose Custom…, type something like 90, 1h30 or 2h 15m, and press Return. The longest timed session is 7 days.

When the time runs out, the session ends and the Mac goes back to its normal sleep settings. A few details:

  • Keep Display On is on by default. Turn it off in the right-click menu or the panel if only the Mac needs to stay awake and the screen may sleep.
  • 5 minutes before a timed session ends, a notification offers +30 Min and +1 Hour buttons.
  • You can choose what happens when a session runs out on its own: Turn Off the Display, Start the Screen Saver, Lock the Screen or Sleep the Mac. Set it in Settings ▸ Sessions ▸ When a Session Ends. It doesn't fire when you stop the session yourself.
  • On a MacBook running on battery, Glowmoth pauses when the battery drops below 20% (the default). It also pauses if macOS reports the Mac is running hot. Both limits are in Settings ▸ Safety.

All session options are in the keep-awake sessions doc.

Keep it awake only while something is running

Here the built-in options fall short. System Settings can't tie sleep to a task. caffeinate can follow a command you start from it, or a process ID you look up yourself, and nothing else.

Glowmoth holds the Mac awake while a task runs and lets it sleep when the task is done:

  • While an app is open. Right-click the icon, open Keep Awake While and pick an open app. The hold ends when that app quits.
  • While a process runs. Choose Keep Awake While ▸ A Process Runs…, search by name or PID, and click Keep Awake. The hold ends when the process exits.
  • Until a download finishes. Choose Keep Awake While ▸ This Download Finishes. The first time, pick the folder the file is saving to, and Glowmoth remembers it. It holds the Mac for at least 2 minutes, then until the folder has been quiet for 2 minutes.
  • Every time, automatically. In Settings ▸ Automation, add apps, process names (such as ffmpeg) or folders. Saved folders count as busy while they hold a partial download (Safari, Chrome, Firefox and Opera partial files are recognized) or a file in them is growing. Glowmoth checks only file names and sizes, never contents.
  • Under conditions. Rules keep the Mac awake while their conditions are true. The Docked at Desk preset holds it while it's on AC power with an external display connected. Office Hours holds it on weekdays from 9:00 to 18:00. Other conditions include a Wi-Fi network, a VPN connection, audio playing and CPU busy. Rules keep only the Mac awake unless you turn on the rule's own Keep the display on switch. See automatic rules.
  • From the command line. Install Glowmoth's tool in Settings ▸ Advanced ▸ Command Line. Then glowmoth run -- make keeps the Mac awake while make runs and returns its exit code.

For downloads in particular, see keep your Mac awake until a download finishes. For Claude Code, Codex and similar tools, see keep your Mac awake while coding agents run.

Glowmoth isn't sold on its own. It comes with MacSuite, a bundle of Mac apps that costs $349 as a one-time purchase (as of November 2026), and each app has a 7-day free trial. If you only need the Mac awake now and then, caffeinate is free and does the job. Other apps, including free ones, are compared in best keep-awake apps for Mac.

What the lid and manual sleep still do

None of the methods above stop these:

  • Closing a MacBook's lid. The Mac sleeps unless it has power and an external display connected (clamshell mode). caffeinate -d and -i don't change this, and neither does a Glowmoth session. Setup steps are in clamshell mode on Mac.
  • Choosing Sleep yourself. Apple menu ▸ Sleep and the power button still put the Mac to sleep. Keep-awake tools only block idle sleep.
  • A nearly empty battery. macOS puts the Mac to sleep to protect your work, whatever you've set.
  • A sleep or shutdown schedule. One set earlier with pmset still runs. Check with:
bash
pmset -g sched

This lists scheduled power events and changes nothing.

Which method should you use

Your situationBest methodWhy
Desktop Mac, or MacBook always on the charger, that should never idle-sleepSystem SettingsSet it once
Screen must stay on for reading, a presentation or a dashboardLock Screen set to Never, or caffeinate -dKeeping the display on also keeps the Mac awake
One long job, and you're fine with Terminalcaffeinate -i or caffeinate -i <command>Free, built in, nothing to undo
Awake for 2 hours, or until 18:00, then sleep normallycaffeinate -t for a length, or a Glowmoth timed session for a length or clock timeSleep comes back on its own
MacBook on battery for a long jobcaffeinate -i, or Glowmoth with its battery floorThe Battery switch only works on the power adapter
Only while an app is open, a process runs or a download finishesGlowmoth Keep Awake While or saved listsEnds when the task does
Only when docked, on a certain Wi-Fi network or during work hoursGlowmoth rulesConditions switch it on and off
Lid closedClamshell mode: power plus an external displayIdle-sleep tools don't affect the lid

For keeping only the screen on, see how to keep your Mac screen on.

If your Mac still goes to sleep

  • The lid was closed or Sleep was chosen. These override every method here. See the section above.
  • The MacBook was on battery. Prevent automatic sleeping on power adapter… only works while plugged in. Use caffeinate -i or an app on battery.
  • The Terminal window was closed. That ends caffeinate. Run it again and leave the window open.
  • The screen went dark, but the Mac didn't actually sleep. caffeinate -i and Glowmoth with Keep Display On turned off let the screen sleep on purpose. Use -d, or turn Keep Display On back on.
  • Glowmoth paused or stopped. A slash on the menu bar icon means a battery or heat limit paused it. The panel explains why and offers Resume Anyway (30 min). Automatic reasons (apps, folders, rules) are ignored while the panel is set to Manual, and after Stop Everything until you start a session again. Once the trial ends without a license, Glowmoth keeps nothing awake. The Glowmoth troubleshooting page covers each case.
  • The Mac sleeps at the same time every day. A pmset schedule is the likely cause. Run pmset -g sched to check.

More causes are in Mac keeps going to sleep. If your Mac has the opposite problem and won't sleep at all, see Mac won't sleep.

FAQ

Is it bad to keep a Mac awake all the time? A Mac awake with the screen off uses more power than a sleeping one, and a screen kept on uses more again. On a desktop that's an energy cost. On a MacBook running on battery, the battery drains faster.

Will my Mac still lock while it's kept awake? If a tool holds the display on (caffeinate -d, or Glowmoth with Keep Display On), the screen won't turn off from inactivity. If you keep only the Mac awake (caffeinate -i, or Glowmoth with Keep Display On off), the screen still turns off and locks according to your Lock Screen settings.

Can I keep a MacBook awake with the lid closed on battery? Not with the built-in settings or caffeinate -d/-i. macOS's clamshell mode needs power and an external display.

Every app.
One purchase.