Skip to content
86% off$349 $48.86code BF2026

Guides

caffeinate Not Working on Mac: Why the Screen Still Sleeps

caffeinate not working and the screen still goes dark? Check pmset -g assertions, then fix -i vs -d, -s on battery, a closed lid and a dead process.

TroubleshootingUpdated 7 min read

On this page

You ran caffeinate, walked away, and came back to a dark screen or a Mac that went to sleep anyway. People report this during OS upgrades, with the lid closed, and from launchers such as Alfred workflows (one report reads "Caffeinate is not running even after trying to enable multiple times"). The command is usually fine. The flag, the process lifetime or the lid is the problem.

Why it happens

Most common first:

  1. You kept the display asleep without realizing it. With no flags, caffeinate behaves like -i. That blocks idle system sleep only, so the display can still turn off.
  2. The process ended. The assertion lives only as long as the caffeinate process. Closing the Terminal window, a dropped SSH session, a finished command, a -t timeout or a restart ends it.
  3. The lid is closed. -i and -d stop idle sleep. Apple lists closing the display on a Mac laptop as its own way to put the Mac to sleep, which is a different trigger (see Apple's page on putting your Mac to sleep or waking it).
  4. You used -s on battery. -s only applies on AC power.
  5. Something else ended the session. Apple menu Sleep, the power button, a scheduled pmset sleep or shutdown, an auto log-out, or a flat battery.
  6. A wrapper never started it. An Alfred workflow, Hammerspoon script or shortcut may fail to launch the command at all.

Step 1: check whether caffeinate holds an assertion

Start a test in one Terminal window. It exits after 60 seconds:

bash
caffeinate -d -t 60

In a second window, run this read-only command:

bash
pmset -g assertions

It lists every sleep-blocking assertion and the process that holds it. Read the output like this:

What you seeWhat it meansGo to
No line naming caffeinateThe process isn't runningStep 3
PreventUserIdleSystemSleep is 1, PreventUserIdleDisplaySleep is 0Mac stays awake, display can sleepStep 2
caffeinate is listed, Mac still sleepsLid, manual sleep, schedule or low batterySteps 4 to 6
You used -s and nothing is listed on battery-s needs AC powerStep 5

Step 2: keep the screen on with -d

If the screen goes dark but the Mac is still running, you used -i or no flag. Add -d:

bash
caffeinate -di

-d prevents display sleep and -i prevents idle system sleep. Press ⌃C (Control-C) to stop it.

If you only need a long job to finish and don't care about the screen, a dark display with -i is working as designed. Check the assertions before assuming the Mac is asleep.

Step 3: make sure the process stays alive

If pmset -g assertions shows no caffeinate line, the process is gone. Common ways that happens:

  • You closed the Terminal window or tab, or an SSH session dropped.
  • A -t timeout ran out. -t is in seconds, so -t 3600 is one hour.
  • You ran caffeinate some-command and that command finished.
  • The Mac restarted, which OS upgrades and updates usually do.

Pick the fix that matches the job:

  • Fixed length: use a timeout longer than the job, for example caffeinate -di -t 14400 for 4 hours.
  • Until a process exits: tie it to a PID with -w:
bash
caffeinate -di -w 12345

Replace 12345 with the PID of the process to wait for. caffeinate exits when that process does.

  • Wrap the command itself: caffeinate -di ./build.sh holds the assertion until the script ends.

Without -t or -w, caffeinate runs until you stop it, so it never turns itself off. To stop every caffeinate process owned by your user:

bash
pkill caffeinate

Nothing to undo; start it again if you want it back.

Step 4: the lid is closed

Symptom: you start caffeinate -d, close the lid, and the Mac sleeps. One reported case is an AppleScript run pausing when the lid closed.

Why: no caffeinate flag stops lid-close sleep. A MacBook normally stays awake with the lid closed only when it has power and an external display connected. Apple's page on an external display that is dark says the Mac should be on power with an external keyboard and mouse in that setup.

Fix: leave the lid open, or use the clamshell setup described in Clamshell Mode on Mac.

Step 5: -s does nothing on battery

-s is only valid while the Mac runs on AC power. Plug in, or use -i or -d on battery.

Step 6: you or something else put the Mac to sleep

An idle assertion doesn't block everything. Apple menu Sleep and the power button still sleep the Mac. A scheduled pmset sleep or shutdown, an automatic log-out after inactivity, or a battery that runs flat will also end your session.

To see scheduled power events:

bash
pmset -g sched

This is read-only. If it lists a sleep or shutdown time, that is your culprit. For the log-out setting, open System Settings and search for "log out".

Step 7: test your launcher separately

If an Alfred workflow, Hammerspoon script or shortcut starts caffeinate and nothing happens, test from Terminal first. If caffeinate -di -t 60 shows a line in pmset -g assertions, the command works and the wrapper isn't launching it. If it doesn't, the cause is one of the steps above.

Flag reference

FlagWhat it doesGotcha
-iPrevents idle system sleep (default with no flags)Display can still sleep
-dPrevents display sleepDoesn't stop lid-close or manual sleep
-sPrevents system sleepAC power only
-mPrevents disk idle sleepDisk only
-uDeclares the user activeTurns the display on if it's off
-t NEnds after N secondsSeconds, not minutes
-w PIDEnds when that process exitsNeeds the PID

Run man caffeinate to confirm these against your macOS version. For more examples, see caffeinate Command on Mac.

Checklist before you try again

  • pmset -g assertions shows a caffeinate line while your job runs.
  • You used -d if you want the screen on.
  • The Terminal window or SSH session stays open, or the command is wrapped around the job.
  • The lid is open, or you have power plus an external display.
  • If you used -s, the Mac is on AC power.
  • pmset -g sched shows no sleep or shutdown scheduled during the job.

Where Glowmoth fits

We make Glowmoth, so weigh this accordingly. caffeinate is enough for a one-off command in a terminal you're keeping open. Glowmoth is a menu bar app that covers part of the same ground, and it is part of MacSuite (7-day free trial).

caffeinateClosest Glowmoth equivalent
-iA session with Keep the display on off
-dA session with Keep the display on on (the default)
-t 7200glowmoth for 2h
-w PIDglowmoth wait <pid>
caffeinate commandglowmoth run -- command
-s, -m, -uNo equivalent

A session started with glowmoth on or glowmoth for lives in the menu bar app, so closing Terminal doesn't end it. Its assertion shows in pmset -g assertions as "Glowmoth: " plus the reason. Glowmoth can also pause on low battery (below 20% by default) or when macOS reports the Mac running hot, and caffeinate has no such limits.

On MacBooks, Settings > Safety > Closed Lid has Stay awake with the lid closed. It installs a helper you approve in System Settings under General, Login Items, and it works only while Glowmoth is keeping the Mac awake. Hardware verification of this mode was still pending as of November 2026. Glowmoth also doesn't block manual sleep, and it needs an active trial or license. Details: Keep a MacBook awake with the lid closed and The glowmoth command-line tool.

If nothing works

If pmset -g assertions shows the right assertion, the lid is open, you're on power and the Mac still sleeps, contact Apple Support. Apple also has a page on what to check when a Mac sleeps or wakes unexpectedly. For Glowmoth problems, use MacSuite support. Include your macOS version, the exact command, and the pmset output taken while it was running.

text
My Mac sleeps even though caffeinate is running.
macOS version: [your version]
Command: caffeinate -di -t 3600
Lid: open / closed. Power: AC / battery.
Attached: output of pmset -g assertions (taken while running)
Attached: output of pmset -g sched
What I already tried: -d instead of -i, keeping Terminal open.

Common questions

Does caffeinate stay on forever?

Without -t or -w, it runs until you press ⌃C, close its window or restart the Mac. If you forget it, pmset -g assertions will show it.

Do I need sudo?

No. Run caffeinate as your normal user.

Why does the screen dim if the Mac stays awake?

That is the -i behavior: the system stays awake and the display may sleep. Add -d to keep the screen on.

Can caffeinate keep a Mac awake with the lid closed?

No. See Step 4. For the broader picture, see Mac Won't Sleep? and How to Stop Your Mac From Going to Sleep.

Every app.
One purchase.