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:
- You kept the display asleep without realizing it. With no flags,
caffeinatebehaves like-i. That blocks idle system sleep only, so the display can still turn off. - The process ended. The assertion lives only as long as the
caffeinateprocess. Closing the Terminal window, a dropped SSH session, a finished command, a-ttimeout or a restart ends it. - The lid is closed.
-iand-dstop 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). - You used
-son battery.-sonly applies on AC power. - Something else ended the session. Apple menu Sleep, the power button, a scheduled
pmsetsleep or shutdown, an auto log-out, or a flat battery. - 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:
caffeinate -d -t 60In a second window, run this read-only command:
pmset -g assertionsIt lists every sleep-blocking assertion and the process that holds it. Read the output like this:
| What you see | What it means | Go to |
|---|---|---|
No line naming caffeinate | The process isn't running | Step 3 |
PreventUserIdleSystemSleep is 1, PreventUserIdleDisplaySleep is 0 | Mac stays awake, display can sleep | Step 2 |
caffeinate is listed, Mac still sleeps | Lid, manual sleep, schedule or low battery | Steps 4 to 6 |
You used -s and nothing is listed on battery | -s needs AC power | Step 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:
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
-ttimeout ran out.-tis in seconds, so-t 3600is one hour. - You ran
caffeinate some-commandand 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 14400for 4 hours. - Until a process exits: tie it to a PID with
-w:
caffeinate -di -w 12345Replace 12345 with the PID of the process to wait for. caffeinate exits when that process does.
- Wrap the command itself:
caffeinate -di ./build.shholds 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:
pkill caffeinateNothing 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:
pmset -g schedThis 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
| Flag | What it does | Gotcha |
|---|---|---|
-i | Prevents idle system sleep (default with no flags) | Display can still sleep |
-d | Prevents display sleep | Doesn't stop lid-close or manual sleep |
-s | Prevents system sleep | AC power only |
-m | Prevents disk idle sleep | Disk only |
-u | Declares the user active | Turns the display on if it's off |
-t N | Ends after N seconds | Seconds, not minutes |
-w PID | Ends when that process exits | Needs 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 assertionsshows acaffeinateline while your job runs.- You used
-dif 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 schedshows 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).
| caffeinate | Closest Glowmoth equivalent |
|---|---|
-i | A session with Keep the display on off |
-d | A session with Keep the display on on (the default) |
-t 7200 | glowmoth for 2h |
-w PID | glowmoth wait <pid> |
caffeinate command | glowmoth run -- command |
-s, -m, -u | No 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.
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.