How to stop your Mac from sleeping (MacBook, iMac, Mac mini)

Written by Jeff Pascal · Updated (Checked on 18 November 2026 against Apple Support and the caffeinate and pmset manuals) · 5 minute read

In short

  • MacBook: System Settings > Battery > Options > turn on "Prevent automatic sleeping on power adapter when the display is off". It works only while plugged in.
  • iMac, Mac mini, Mac Studio: System Settings > Energy > turn on "Prevent automatic sleeping when the display is off".
  • For a few hours without changing settings, run caffeinate in Terminal. It keeps the Mac awake until you press Control-C.
  • A closed MacBook stays awake only with power, an external display and an external keyboard and mouse.

To stop a Mac from sleeping, change one setting. On a MacBook, open System Settings > Battery > Options and turn on Prevent automatic sleeping on power adapter when the display is off. On an iMac, Mac mini or Mac Studio, open System Settings > Energy and turn on Prevent automatic sleeping when the display is off. For a one-off, type caffeinate in Terminal instead.

The screen can still turn off. Downloads, backups, renders and background apps keep going. Below: the steps, the Terminal command and its options, the closed-lid rules, and how to check what is keeping your Mac awake. Menu names are from macOS 26; older versions can differ a little.

Display sleep and system sleep are two different things

Most "my Mac keeps sleeping" problems come from mixing these up:

  • Display sleep turns the screen off. Set it in System Settings > Lock Screen ("Turn display off on battery when inactive" and "Turn display off on power adapter when inactive"). Your apps keep running.
  • System sleep pauses the whole Mac. Downloads stop, network connections drop, background jobs freeze.

You usually want the display to sleep and the system to stay awake. The settings below do that.

On a MacBook (Air or Pro)

  1. Plug in the power adapter.
  2. Choose Apple menu > System Settings, then click Battery in the sidebar.
  3. Click Options.
  4. Turn on Prevent automatic sleeping on power adapter when the display is off.
  5. Optional: set Wake for network access so other devices can reach shared folders while it rests.

This is Apple's own path (Apple: sleep and wake settings). Note the words "on power adapter": on battery, the MacBook still sleeps on its normal schedule.

On an iMac, Mac mini or Mac Studio

  1. Choose Apple menu > System Settings, then click Energy in the sidebar.
  2. Turn on Prevent automatic sleeping when the display is off.
  3. Optional: turn on Wake for network access.

If you want a desktop Mac running around the clock, as a file server or for an AI assistant, the full checklist (power-cut restart, remote access, firewall) is in Mac mini as a server.

With Terminal: caffeinate

macOS includes caffeinate, a command that keeps the Mac awake while it runs. Open Terminal (in Applications > Utilities) and type:

caffeinate -i

The Mac stays awake until you close that Terminal window or press Control-C. The options, from the manual (man caffeinate):

Option What it does
-i stops idle sleep of the system (the default if you give no option)
-d keeps the display awake too
-m stops the disk from idle sleeping
-s stops system sleep, but only while on AC power
-u declares the user active and turns the display on (5 seconds unless you add -t)
-t 3600 lets go after 3,600 seconds (one hour)
-w 1234 holds until the process with ID 1234 exits

Two handy forms:

  • caffeinate -i -t 7200 keeps the Mac awake for two hours, then stops by itself.
  • caffeinate -i ./long-job.sh keeps it awake only while that script runs.

With the lid closed

A closed MacBook goes to sleep, with one supported exception. Apple's display help says that a Mac laptop with a closed lid must be connected to power and use an external keyboard and mouse (Apple: external display), plus the external display itself. People call this clamshell mode.

Without an external display, the safe choice is to leave the lid open and let the screen turn off.

You will find sudo pmset -a disablesleep 1 shared online as a way to keep a closed MacBook awake with no display. It is not in Apple's pmset manual. If you try it, keep the laptop plugged in, on a hard surface (a closed laptop runs warmer), and undo it with sudo pmset -a disablesleep 0.

Check what is keeping your Mac awake (or not)

Two Terminal commands from the pmset manual:

  • pmset -g shows the power settings in use right now. A sleep value of 0 means the system sleep timer is off.
  • pmset -g assertions lists the apps and processes that are currently preventing sleep. Run caffeinate -i in one window and this in another, and you will see caffeinate in the list.

If your Mac still sleeps:

  1. Is it on battery? The MacBook setting works only on the power adapter.
  2. Did you change the display timer (Lock Screen) instead of the sleep setting?
  3. Was the lid closed without an external display?

Running a MacBook as an always-on machine

Some people keep an old MacBook running as a home server or for a personal AI assistant. That adds three questions.

Power cuts. On a short cut, the battery takes over and the MacBook keeps running. If the outage outlasts the battery, the MacBook shuts down; plan to start it yourself, and treat sudo pmset -a autorestart 1 (the pmset setting for automatic restart on power loss) as something to test on your own model.

Login after a restart. Apps you start yourself run only once you are logged in. System Settings > Users & Groups > Automatically log in as does it for you, but Apple notes the option is dimmed while FileVault is on (Apple: automatic login). On a laptop you carry around, keep FileVault on and log in by hand after a restart.

Heat. A laptop that runs all day should sit on a hard surface with air around it.

The quick test: leave the MacBook plugged in, screen off, untouched for an hour. Then use whatever it is running (a download, a shared folder, a message to the assistant). If it answers, the settings hold.

If your Mac still nods off while running an AI assistant, bring the snag to Team of One. It is a free WhatsApp community I run where we learn to amplify our work with AI.

If you have a Windows PC instead, the same steps are in how to stop your computer from sleeping.

Checked on 18 November 2026 against Apple Support and the caffeinate and pmset manuals.

Questions

How do I keep my Mac awake without an app?

Use the built-in setting (Battery > Options on a MacBook, Energy on a desktop Mac) or type caffeinate -i in Terminal. Both are part of macOS; you do not need Amphetamine or any other download.

How do I stop my MacBook from sleeping when the lid is closed?

Apple supports a closed lid only when the MacBook is on power and connected to an external display, keyboard and mouse. Without a display, leave the lid open and let the screen turn off instead.

Why does my Mac still go to sleep?

The usual reasons: the MacBook is on battery (the setting works only on the power adapter), the lid was closed without an external display, or you changed the display timer instead of the sleep setting. In Terminal, pmset -g shows the settings in use.

Does caffeinate keep the screen on?

Only with -d. caffeinate -i keeps the system awake and lets the display turn off; caffeinate -d keeps the display awake too.

Is it bad to never let a Mac sleep?

Preventing sleep can increase power use. Letting the display turn off while the system stays awake saves most of it.

Sources

  1. Apple Support: Set sleep and wake settings for your Mac: Lock Screen display timers; laptops: Battery > Options; desktops: Energy, checked 18 November 2026
  2. Apple Support: A display on a Mac laptop with a closed lid: the Mac must be connected to power and use an external keyboard and mouse, checked 18 November 2026
  3. ss64.com (copy of the macOS man page): caffeinate manual page: -d, -i, -m, -s (valid only on AC power), -u, -t timeout, -w pid (man caffeinate in Terminal), checked 18 November 2026
  4. ss64.com (copy of the macOS man page): pmset manual page: -g shows current settings, -g assertions lists what prevents sleep, autorestart, womp (man pmset in Terminal), checked 18 November 2026
  5. Apple Support: How to log in automatically to a Mac user account; dimmed when FileVault is turned on, checked 18 November 2026

Free WhatsApp community

Learning AI? Learn it on real work.

In “Team of one” I post what I actually tried on my own work. Most of it is in Romanian, but ask in English any time and we will work it out together.

Join the community