Guide · Updated 2026-10

How to stop your Mac from sleeping

Four ways, from a switch in System Settings to a command in Terminal. Which one you want depends on how long the Mac needs to stay awake, whether it's plugged in, and whether the lid will be closed.

The short answer

Plugged-in MacBook: System Settings › Battery › Options › turn on Prevent automatic sleeping on power adapter when the display is off. Mac mini, iMac, Mac Studio, Mac Pro: System Settings › Energy › turn on Prevent automatic sleeping when the display is off. Just for one job: run caffeinate -i in Terminal. On battery, with the lid closed, or until a set time: System Settings can't do it; use pmset or an app.

Which method to use

Your situationUse
MacBook, plugged in, every daySystem Settings › Battery › Options
Mac mini, iMac, Mac Studio, Mac ProSystem Settings › Energy
One download, build, or commandcaffeinate in Terminal
MacBook on batterycaffeinate, or an app with a battery floor
Lid closedAn external display (clamshell mode), pmset, or an app with closed-lid mode
Until 7 AM, while an app runs, or every weekday 9 to 5An app

1. System Settings

Since macOS Ventura, sleep settings live in System Settings. The names below are the same in Ventura, Sonoma, Sequoia, Tahoe, and Golden Gate.

On a MacBook

  1. Open System Settings › Battery.
  2. Click Options… at the bottom of the pane.
  3. Turn on “Prevent automatic sleeping on power adapter when the display is off.” The Mac now stays awake whenever it's plugged in, even after the screen goes dark.

The screen still turns off on its own schedule. That's set separately in System Settings › Lock Screen › Turn display off on power adapter when inactive. Leaving the display free to sleep is usually what you want: the Mac keeps working and saves power. To keep the screen on too, see how to keep your Mac screen on.

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

  1. Open System Settings › Energy.
  2. Turn on “Prevent automatic sleeping when the display is off.”

What this can't do

The switch only works on the power adapter, so a MacBook on battery still sleeps. Closing the lid still sleeps it. And it's all or nothing: there's no “until the download finishes” or “until 7 AM,” so you have to remember to turn it back off.

2. The caffeinate command

Every Mac includes caffeinate, a Terminal command that holds the Mac awake until you stop it. It works on battery and needs no admin password.

caffeinate -i              # stay awake until you press Ctrl-C
caffeinate -i -t 7200      # for two hours
caffeinate -d              # keep the display on too
caffeinate -i ./build.sh   # for as long as this command runs

It stops when you press Ctrl-C or close the Terminal window, and it doesn't keep a closed lid awake. There's more on the flags and the catches in the caffeinate guide.

3. pmset, for full control

pmset changes the power settings directly. It needs an admin password, and its changes stay until you change them back.

pmset -g                          # see the current settings
sudo pmset -c sleep 0             # never sleep on the charger
sudo pmset -b sleep 0             # never sleep on battery
sudo pmset -a disablesleep 1      # never sleep at all, even with the lid closed
sudo pmset -a disablesleep 0      # undo that

-c means on the charger, -b on battery, and -a both. Before changing sleep, note the value pmset -g shows so you can put it back.

Be careful with disablesleep 1 on a laptop. It applies to the whole Mac and doesn't turn itself off. Forget about it and a MacBook in a bag keeps running, with nowhere for its heat to go.

4. A keep-awake app

An app makes sense when you want the Mac awake for a reason and then back to normal, without remembering to undo anything. Midnight Oil is free and lives in the menu bar:

  • Keep Awake For a set time, or Keep Awake Until a clock time like 7:00 AM.
  • While App Is Running: stays awake until Terminal, Cursor, or Final Cut quits.
  • While File Is Downloading: stops when the download finishes.
  • Stay awake with lid closed, with sleep restored automatically when the session ends, the app quits, or anything crashes.
  • Schedules like weekdays 9 to 5, and battery safety that ends sessions when you unplug or drop below a level you choose.

Other options: KeepingYouAwake is a good minimal on/off switch, and Amphetamine still works but hasn't been updated since 2023.

By Mac model

MacBook Air

Use Battery › Options when plugged in. The Air has no fan, so if you keep it awake with the lid closed, leave it somewhere open rather than in a sleeve.

MacBook Pro

Same settings as the Air. For long jobs on battery, set a battery floor so a session ends before the battery runs out.

Mac mini, Mac Studio, iMac

System Settings › Energy is usually all you need, since there's no battery or lid. A Mac mini used as a home server is the classic case for leaving Prevent automatic sleeping when the display is off on permanently.

If your Mac still falls asleep

  • It's on battery. The System Settings switch only applies on the power adapter.
  • The lid closed. A closed lid sleeps a MacBook unless it's in clamshell mode or sleep is disabled.
  • A scheduled sleep. Run pmset -g sched. Cancel a repeating one with sudo pmset repeat cancel.
  • Something else is fighting it. pmset -g assertions lists every app holding the Mac awake, or not.
  • It's the external drive that's sleeping. Turn off Put hard disks to sleep when possible in Battery › Options or Energy, or use Midnight Oil's Drive Alive to keep just the drives you pick awake.

Questions

How do I stop my Mac from going to sleep?

On a MacBook, open System Settings › Battery › Options and turn on Prevent automatic sleeping on power adapter when the display is off. On a desktop Mac, open System Settings › Energy and turn on Prevent automatic sleeping when the display is off. For a one-off job, run caffeinate -i in Terminal and press Ctrl-C when you're done.

How do I keep my MacBook from sleeping on battery?

System Settings only offers the prevent-sleep switch on the power adapter. On battery, run caffeinate -i in Terminal, or use a keep-awake app such as Midnight Oil, which can also end the session when the battery drops below a level you choose.

How do I turn off sleep mode on a Mac completely?

sudo pmset -a disablesleep 1 in Terminal turns off all sleep, including when the lid closes. It stays that way until you run sudo pmset -a disablesleep 0, so use it with care on a laptop: a MacBook that never sleeps can drain its battery or overheat in a bag.

Why does my Mac still go to sleep?

Check three things. The prevent-sleep switch only works on the power adapter, so a MacBook on battery still sleeps. Closing the lid always sleeps the Mac unless an external display, power, and keyboard are connected, or sleep is disabled with pmset. And a scheduled sleep can override everything: run pmset -g sched to see one.

Does keeping a Mac awake damage it?

No. Macs are built to run for days. Keep it ventilated, and let the display sleep when you don't need it, which saves power and the screen. Midnight Oil's Allow display sleep option does exactly that while the Mac keeps working.

Keep your Mac awake in one click.

Free. No account, no subscription.

macOS 14 or later · Apple Silicon and Intel · brew install --cask coreyhaines31/tap/midnightoil