Why Your Mac Keeps Going to Sleep
By default, macOS puts your Mac to sleep after a period of inactivity to save energy. This is usually a good thing, but there are many situations where you need your Mac to stay awake: downloading large files, running long scripts or renders, giving presentations, hosting a server, performing backups, or simply keeping a display active for reference.
The challenge is that macOS gives you limited control. You can change when sleep kicks in, but you cannot easily toggle it on and off, set timers, or create smart rules. Here is every method available, from built-in settings to dedicated tools.
Method 1: Change System Settings (Free, Built-in)
The most straightforward approach is to change your sleep timer in System Settings.
Steps:
Open System Settings (click the Apple menu > System Settings).
Go to Lock Screen and set "Turn display off when inactive" to Never.
For desktop Macs, also check Energy Saver and enable "Prevent automatic sleeping when the display is off".
For MacBooks on battery, check Battery > Options for additional sleep settings.
Limitations
This is an all-or-nothing approach. Setting the timer to "Never" means your Mac will never sleep on its own, which wastes electricity and accelerates screen burn-in on OLED displays. You have to manually change the setting back when you are done, and most people forget. There are no timers, no schedules, and no smart triggers.
Method 2: Use the caffeinate Terminal Command
macOS includes a built-in command called caffeinate that temporarily prevents sleep from Terminal. It is surprisingly powerful once you know the flags.
Steps:
Open Terminal (search in Spotlight or find it in Applications > Utilities).
Type caffeinate and press Enter. Your Mac will stay awake until you press Ctrl+C or close Terminal.
With a timer: caffeinate -t 3600 keeps your Mac awake for 3600 seconds (1 hour).
With display: caffeinate -d also prevents the display from sleeping (not just the system).
With a process: caffeinate -w 12345 keeps awake until process ID 12345 finishes.
Useful caffeinate Flags
-d Prevent display sleep
-i Prevent idle sleep
-s Prevent system sleep (keeps awake even on battery)
-t N Set timeout in seconds
-w PID Wait for process to finish
Limitations
You need to keep Terminal open. Closing the window or accidentally pressing Ctrl+C stops it. There is no visual indicator in the menu bar showing whether caffeinate is active. No schedule support. No app-based triggers. You have to remember the command and its flags every time. If Terminal crashes, sleep prevention stops immediately.
Method 3: Use Hot Corners as a Quick Toggle
Hot Corners let you assign actions to screen corners. While there is no "prevent sleep" option, you can use "Disable Screen Saver" as a partial workaround.
Steps:
Open System Settings > Desktop & Dock and scroll to the bottom.
Click Hot Corners and assign "Disable Screen Saver" to a corner.
Before a presentation or long task, move your cursor to that corner to activate it.
Limitations
This only prevents the screen saver, not actual system sleep. It is easy to accidentally trigger Hot Corners during normal use. There is no timer, no automation, and it does not prevent the display from dimming. It is more of a workaround than a real solution.
Method 4: Use a Dedicated Menu Bar App (Best Solution)
The most convenient way to control Mac sleep is with a dedicated menu bar app. Espresso lives in your menu bar and lets you toggle sleep prevention with a single click, set timers, and create smart automation rules.
Steps:
Download Espresso from the Mac App Store.
Espresso appears in your menu bar. Click it to toggle sleep prevention on or off instantly.
Set a timer to automatically re-enable sleep after a specific duration (30 min, 1 hour, 2 hours, custom).
Configure app-based triggers to automatically keep your Mac awake when specific apps are running (e.g., a video editor, download manager, or virtual machine).
Why This Works Best
One click to toggle, always visible in the menu bar so you know the current state. Timers ensure you never forget to re-enable sleep (saving battery and screen life). App-based triggers are the real game-changer: set it once, and your Mac stays awake automatically when you are running heavy tasks, then sleeps normally when you are done. No Terminal commands, no changing system settings back and forth.
Common Scenarios
Downloading Large Files
Set a timer or use caffeinate with your download process. A menu bar app is ideal because you can see at a glance whether sleep prevention is active.
Giving Presentations
You need both display sleep and system sleep disabled. Use caffeinate -d or toggle Espresso before starting your presentation.
Running Long Builds or Renders
App-based triggers shine here. Configure your Mac to stay awake automatically whenever Xcode, Final Cut, or Handbrake is running.
Hosting a Local Server
If your Mac runs a local dev server or file server, it must stay awake. Use the Energy Saver setting or a persistent toggle from a menu bar app.
Quick Comparison
| Method | Quick Toggle | Timer | App Triggers | Visual Status |
|---|---|---|---|---|
| System Settings | No | Fixed only | No | No |
| caffeinate | Terminal | Yes (-t) | PID only | No |
| Hot Corners | Corner | No | No | No |
| Espresso | 1 Click | Yes | Yes | Menu Bar |