How to Keep Your Mac Awake

Stop your Mac from sleeping during downloads, presentations and long builds. Three ways to keep it awake: System Settings, the caffeinate command, and the free Coffee extension.

UPDATED

Your Mac goes to sleep to save power. That's great until it happens in the middle of a 40 GB download, a long build, or a slide you've been talking over for five minutes.

The short answer: to keep your Mac awake for a while, run caffeinate -d in Terminal, or install the free Coffee extension for Raycast and run Caffeinate. To change it for good, go to System Settings → Lock Screen and set the display to never turn off.

This guide walks through all three, and when to use each.

MethodBest forTime limitStays on after restart
Coffee for RaycastEveryday use, one keystrokeYes: for, until, while an app runs, scheduleOptional
caffeinate in TerminalOne-off, scriptsYes, in secondsNo
System SettingsNever sleeping, permanentlyNoYes

Keep your Mac awake with Raycast

Coffee: keep your Mac awake with one keystrokeInstall

Coffee is a free extension with more than 160,000 installs. It uses macOS's own caffeinate command under the hood, so it's as reliable as Terminal, and you never have to touch your settings.

Open Raycast and type one of these:

Type “caff” in Raycast to see all of Coffee’s commands.
Type “caff” in Raycast to see all of Coffee’s commands.
  • Caffeinate: keep your Mac awake until you stop it.
  • Caffeinate for…: stay awake for a set time, like 1h 30m.
  • Caffeinate Until: stay awake until a time, like 5pm.
  • Caffeinate While: stay awake while an app is running, like Zoom, Xcode or Transmission.
  • Schedule Caffeination: stay awake on set days and hours, like weekdays 9 to 6.
  • Decaffeinate: let your Mac sleep again.

Turn on Caffeinate Status Menu Bar to see a coffee icon in your menu bar whenever your Mac is being kept awake, and click it to stop.

Pro tip: give Toggle Caffeinate a hotkey in Raycast's settings, like ⌥ ⌘ C. One press keeps your Mac awake, the next one lets it sleep.

You can also just ask. In Raycast AI, type @, pick Coffee and say what you need, like “keep my Mac awake until the download finishes at 3pm”. Coffee sets it up.

By default Coffee keeps the display, the system and the disk awake. In the extension's preferences you can turn any of these off, or keep your Mac awake whenever it's plugged in.

Hotkeys and aliases work on almost any Raycast command, including this one. This three-minute video shows how to set them up:

Use the caffeinate command

Every Mac comes with caffeinate. It keeps your Mac awake for as long as the command is running.

  1. Open Terminal (Applications → Utilities).
  2. Type caffeinate -d and press Return.
  3. Press Control C when you're done.

Useful options:

  • caffeinate -d: keep the display on.
  • caffeinate -i: stop idle sleep but let the display turn off.
  • caffeinate -t 3600: stay awake for 3,600 seconds (one hour), then stop.
  • caffeinate -s: stop system sleep while plugged in.
  • caffeinate -i make build: stay awake only while a command runs.
Pro tip: closing the Terminal window stops caffeinate too, so keep it open while you need it.

Change your sleep settings

If you never want your Mac to sleep, change the settings. This applies all the time until you change it back.

  1. Open System Settings → Lock Screen.
  2. Set Turn display off on power adapter when inactive to Never.
  3. On a MacBook, also go to Battery → Options and turn on Prevent automatic sleeping on power adapter when the display is off.

The downside: your Mac never sleeps, even when you forget about it, which wastes power and shortens battery life. For most people, a time-limited method above is the better choice.

Frequently Asked Questions

How do I stop my Mac from going to sleep?

For a one-off, run caffeinate -d in Terminal or use Coffee in Raycast. To change it permanently, set the display to Never turn off in System Settings → Lock Screen, and on a laptop turn on Prevent automatic sleeping on power adapter in Battery → Options.

Can I keep my Mac awake with the lid closed?

A MacBook sleeps when you close the lid unless it's in clamshell mode: plugged in and connected to an external display, with an external keyboard or mouse.

Does keeping my Mac awake drain the battery?

Yes. A Mac that can't sleep keeps using power, and a screen that stays on uses the most. Use a time limit, like Caffeinate for… or caffeinate -t, so your Mac goes back to normal on its own.

What is caffeinate on Mac?

caffeinate is a command built into macOS that prevents sleep while it runs. Coffee uses it under the hood, so you get the same reliability without opening Terminal.

Is there a free Amphetamine alternative?

Coffee is free and open source, and it covers the common cases: a set time, until a time, while an app runs, and weekly schedules, with a menu bar status. It works on Windows too. If you already use Amphetamine, the Amphetamine extension lets you start and stop its sessions from Raycast.

Keep your Mac awake with one keystroke. Try Raycast with the free Coffee extension.

Download