Does caffeinate work with a MacBook lid closed?

By Matyas Rathonyi. Updated October 8, 2026. Guides

No. caffeinate only blocks idle sleep; closing the lid triggers a separate sleep path, so the Mac still sleeps. Clamshell, a Mac menu bar app, overrides lid sleep itself, so the Mac stays awake with the lid closed, with no sudo and no external display.

Idle sleepBlocked while the process runs
Lid sleepNot blocked; the Mac sleeps on close
The -s flagAC power only, still no lid mode
Lid closing?Use a display, pmset, or a lid app

Clamshell for Mac keeps the Mac awake with the lid closed while armed. No sudo, no monitor. Free for 7 days, then $9.99 once.

Download free trial

Apple Silicon, macOS 14+. Notarized by Apple. 3.6 MB. Or buy now, $9.99. On your phone? Send the Mac download link to yourself.

Two separate sleep paths. caffeinate stands in the idle-sleep path and keeps the Mac awake. The lid-close path has no guard, so it goes straight to sleep. idle caffeinate lid z
Two sleep paths. caffeinate guards one.Its assertion blocks the idle timer. Closing the lid is a separate trigger with nothing in its way, so the Mac goes straight to sleep.

No. caffeinate only prevents idle sleep, and closing a MacBook lid triggers a separate sleep path that it does not override, so the Mac still sleeps as soon as the lid shuts, even with a busy command and an active assertion. To keep working with the lid closed you need an external display, sudo pmset -a disablesleep 1, or a lid-closed app such as Clamshell for Mac, a menu bar app that needs no sudo.

What caffeinate actually promises

The macOS manual says that running caffeinate with no flags creates an assertion that prevents idle system sleep. The assertion lasts until the process exits. That is useful for a build, download, presentation, or terminal job when the lid stays open.

caffeinate -i make
caffeinate -i -w 12345
caffeinate -i -t 3600

The first command keeps idle sleep away while make runs. The second follows a process ID. The third expires after one hour. None of them changes what macOS does when it detects a closed lid.

The same caffeinate job. With the lid open it runs to the end. With the lid closed the Mac sleeps and the job stalls. z Lid open caffeinate holds Lid closed sleeps anyway
Same command, two lids. caffeinate -i make keeps idle sleep away while the lid is open. Close the lid and the separate lid-sleep path takes over, assertion or not.

The flags do not mean closed-lid mode

How to see the assertion

  1. Inspect the assertions. While caffeinate is running, open another Terminal window and inspect the system-wide assertions:
    pmset -g assertions
  2. Find the caffeinate entry. You will normally see PreventUserIdleSystemSleep or another assertion owned by caffeinate. This confirms that the command is working.

It also explains the limitation: power assertions describe kinds of sleep that software would like to avoid, while the lid switch has its own policy.

What works instead

An external display

Apple's supported closed-display setup uses an external display, power, and external input devices.

Apple's display setup explained

An HDMI dummy plug

A dummy plug can imitate the display.

Every method compared

sudo pmset -a disablesleep 1

Another workaround, but it is an undocumented, system-wide, admin-level switch that must be undone manually.

The risks and the undo command

A purpose-built app

A purpose-built app can change only the lid-close behavior for the session and keep the state visible.

What Clamshell for Mac is

Clamshell for Mac is one such app. While armed, it uses the unprivileged IOKit lid sleep-state control that handles the lid, plus the same kind of idle-sleep assertion caffeinate creates, so both sleep paths are covered. It does not use pmset disablesleep or need sudo. Thermal safety is always on, and the lid change is never saved across a restart. The keep-awake mechanisms guide compares every route, including which apps need a helper and what each leaves behind after a crash.

Clamshell keeps the Mac awake when the lid closes, then returns normal sleep behavior when you open it. Free for 7 days, then $9.99 once.

Download free trial

Apple Silicon, macOS 14+. Notarized by Apple. 3.6 MB.

The practical rule

The Mac stays open

Use caffeinate when you want a command to survive idle timers.

The lid will close

Use a closed-display solution when the physical lid will close.

For a full comparison, read Clamshell vs Amphetamine vs pmset. For coding sessions, see keeping Claude Code, Codex, and other agents running, keeping Codex running with the lid closed, and running AI agents overnight. For every option in one place, read how to keep a MacBook awake with the lid closed. Other keep-awake apps hit the same wall: see why KeepingYouAwake sleeps with the lid closed and how to fix Amphetamine not working with the lid closed.

Frequently asked questions

Does caffeinate work with the MacBook lid closed?

No. caffeinate prevents idle sleep. Closing the lid triggers a separate sleep path that caffeinate does not override, so the Mac sleeps when the lid shuts unless an external display, pmset disablesleep, or a lid-closed app is in use.

Does caffeinate -s keep a Mac awake with the lid closed?

Not on its own. The -s flag requests prevention of system sleep and only applies on AC power; it does not configure a MacBook for closed-display operation. Test your own setup with the lid closed before relying on it.

Why does my Mac still sleep when caffeinate is running?

If the lid is open, check pmset -g assertions to confirm the caffeinate assertion exists and that the command it follows is still running. If the lid is closed, lid-close sleep is the cause: caffeinate does not cover it.

What should I use instead of caffeinate when the lid is closed?

Use Apple's external-display setup at a desk, pmset disablesleep if you will remember to undo it, or a lid-closed app. Clamshell for Mac is a menu bar app that keeps the Mac awake with the lid closed without sudo and restores normal lid sleep when you disarm or quit.

Does Clamshell for Mac use caffeinate?

No. Clamshell does not run caffeinate or use pmset disablesleep. While armed it uses the unprivileged IOKit lid sleep-state control and holds its own idle-sleep assertion, so it covers both lid-close sleep and idle sleep.

Method: checked against the macOS caffeinate(8) and pmset(1) manuals and verified with pmset -g assertions on an Apple Silicon MacBook.