Your Mac goes to sleep to save power, which is usually what you want. It is less helpful in the middle of a long download, an export, a build, an AI agent's task or a presentation.
This guide covers three ways to keep your Mac awake, from a permanent setting to a single click.
1. Change your settings in macOS
This is the simplest option if you want your Mac to stay awake all the time while it is plugged in. The exact names can vary a little between versions of macOS.
On a MacBook:
- Open System Settings and choose Battery.
- Click Options.
- Turn on Prevent automatic sleeping on power adapter when the display is off.
On a desktop Mac:
- Open System Settings and choose Energy (Energy Saver on macOS 14).
- Turn on Prevent automatic sleeping when the display is off.
To control how soon the screen turns off, open System Settings > Lock Screen. Apple covers all of these in its sleep and wake settings guide.
This stays on until you change it back, so your Mac no longer sleeps when you walk away, and it uses more power.
2. Use the caffeinate command
Every Mac includes a tool called caffeinate, which keeps it awake for as long as the tool runs. Open Terminal and type:
caffeinate
Your Mac now stays awake until you press Control C or close that Terminal window. A few useful variations:
| Command | What it does |
|---|---|
caffeinate -d | Also keeps the display on |
caffeinate -t 3600 | Stays awake for 3,600 seconds, which is one hour |
caffeinate -i ./export.sh | Stays awake until that command finishes |
caffeinate -w 1234 | Stays awake until the process with that ID exits |
It is already on your Mac and costs nothing. You do need a Terminal window, and you have to remember the options.
3. Use a menu bar app
If you do this often, a menu bar app is easier. Easy Caffeinate is a free app that uses the same built-in caffeinate tool, with a coffee cup in your menu bar.
- Click the cup to keep your Mac awake, and click again to let it sleep.
- Set a timer, from 15 minutes to 8 hours or any length you choose.
- Pick an end time, such as 5:30 PM.
- Follow an app, so your Mac stays awake until that export or download app quits.
- List your apps, so it happens automatically whenever one of them is running.
- Protect your battery by turning off when you unplug or when the charge gets low.
If you run coding agents, see how to keep your Mac awake while AI agents work.
Which one should you use?
| Your situation | Best option |
|---|---|
| A Mac that should always stay on while plugged in | macOS settings |
| A one-off job, and you are comfortable in Terminal | caffeinate |
| You need it regularly, or for certain apps | A menu bar app |
Should the screen stay on?
Often it does not need to. For a download, an export or a build, your Mac can keep working while the display sleeps, which saves power. Keep the display on when you are presenting, reading or watching something.
In Easy Caffeinate, this is the Keep the display on switch in Settings > While Awake.
What about closing the lid?
These options stop your Mac from sleeping when it is idle. Closing the lid of a MacBook normally still puts it to sleep.
To keep working with the lid closed, Apple's supported setup is to connect your MacBook to power, an external display, and an external keyboard and mouse or trackpad.
Easy Caffeinate also has an optional Keep running with the lid closed (on power) setting in Settings > While Awake. It needs a charger and has no effect on battery. macOS can still sleep if your Mac gets too hot, so never run it closed in a bag.