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.
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 trialApple Silicon, macOS 14+. Notarized by Apple. 3.6 MB. Or buy now, $9.99. On your phone? Send the Mac download link to yourself.
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.
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
-iprevents idle system sleep. This is the default assertion and does not override lid-close sleep.-srequests prevention of system sleep and is valid only on AC power. It still does not configure a MacBook for closed-display operation.-dprevents idle display sleep. That is the opposite of the usual lid-closed goal, where the screen should turn off.-mprevents idle disk sleep. It does not affect the lid.-udeclares user activity and can wake the display. It is not a lid override.
How to see the assertion
- Inspect the assertions. While
caffeinateis running, open another Terminal window and inspect the system-wide assertions:pmset -g assertions - Find the caffeinate entry. You will normally see
PreventUserIdleSystemSleepor another assertion owned bycaffeinate. 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 explainedsudo 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 commandA 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 isClamshell 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 trialApple 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.