caffeinate Not Working With the Lid Closed on a MacBook
caffeinate and keep-awake apps can't stop a MacBook sleeping when the lid closes. Here is why, and three fixes: display plus power, pmset, or Glowmoth.
GuideUpdated 7 min read
On this page
You ran caffeinate or a keep-awake app, closed the lid, and the MacBook went to sleep anyway. The VPN dropped, the screen share ended, the call or file transfer stopped, and the long job died with it.
We make Glowmoth, so weigh our view accordingly. The first two fixes need no app from us.
Why caffeinate doesn't keep a MacBook awake with the lid closed
caffeinate and most keep-awake apps ask macOS not to sleep by holding a power assertion. macOS honors those assertions for idle sleep. Closing the lid is not idle sleep, and user-space assertions can't veto it. Theine's own store text says it cannot prevent sleep on a closed MacBook with no additional display connected.
| Flag | What it holds | Lid closed on battery? |
|---|---|---|
-i | Idle system sleep | Mac still sleeps |
-d | Display sleep | Mac still sleeps |
-s | System sleep, only while on AC power | Does nothing on battery |
-s is the one flag aimed at holding the Mac awake beyond idle, and only on power. We haven't verified how it behaves with the lid closed on every macOS version, so treat it as unreliable here.
Glowmoth's normal keep-awake behaves like -i and -d. It never uses the assertion that -s relies on, so closing the lid sleeps the Mac unless closed-lid mode is on. For the full flag list, see caffeinate Command on Mac: Flags and Examples.
Pick a method
| Method | Needs | Works on battery? | Main risk |
|---|---|---|---|
| External display + power adapter | A display and the charger | No, power is part of the rule | None; it's Apple's setup |
| Headless HDMI adapter | A dummy display plug, the charger | Treat it as needing power | Results vary; we haven't tested adapters |
sudo pmset -a disablesleep 1 | Admin password, Terminal | Yes | Easy to forget; a Mac that never sleeps in a bag gets hot |
| Glowmoth closed-lid mode | Glowmoth, one-time helper approval | Yes, above the battery floor | Hardware verification still pending |
Pick the display route if you work at a desk. Pick pmset or Glowmoth if the Mac must stay awake on battery or with nothing attached.
Method 1: external display and power
A MacBook with power and an external display stays awake when you close the lid. This is the only method that needs no workaround.
- Plug in the power adapter.
- Connect an external display.
- Close the lid and keep working on the external display.
People who don't own a display often report using a headless HDMI adapter, a small plug that makes the Mac think a display is attached. We haven't tested any, so check the seller's compatibility notes and plug in power as well. For more, see Clamshell Mode on Mac.
Method 2: turn sleep off with pmset
pmset is built into macOS. This command disables sleep system-wide, including lid-close sleep.
sudo pmset -a disablesleep 1The -a flag applies it to all power sources. To undo it:
sudo pmset -a disablesleep 0To check the current state, look for the SleepDisabled line:
pmset -g | grep -i sleepdisabledIt's a persistent setting, so use it for a specific job, then undo it.
Method 3: Glowmoth's closed-lid mode
Closed-lid mode runs the same pmset step through a small privileged helper, but only while Glowmoth is actually keeping the Mac awake, and with limits you'd otherwise enforce yourself. It covers the lid only: it doesn't keep Wi-Fi or VPN connections alive, and it isn't available on desktop Macs.
- Only during a session. The helper runs
pmset -a disablesleep 1while any Glowmoth reason is active (your session, an app, a rule, an agent, a command-line lease) and Glowmoth isn't paused. It runspmset -a disablesleep 0as soon as that ends. - No display or charger required.
- Battery and heat cut-offs. Both limits are forced on. It switches off immediately when macOS reports serious thermal pressure or worse, and on battery below the floor (20% by default).
- Fail-safe. The app renews a 30-second lease every 10 seconds. If Glowmoth stops responding, normal sleep returns within 30 seconds. If it quits or crashes, or the helper is removed, it returns immediately.
- It leaves your own
pmsetalone. It only undoes a setting Glowmoth itself made.
Turn it on
- Click the moth in the menu bar to open the panel, then choose Settings… (⌘,).
- Open the Safety tab and find Closed Lid.
- Turn on Stay awake with the lid closed.
- Approve the helper when asked. Glowmoth opens System Settings > General > Login Items; allow the Glowmoth helper there.
- Start a session with the Keep Awake switch in the panel. The caption changes to "Active: your Mac stays awake with the lid closed."
- Close the lid. Glowmoth plays the "Glass" sound and posts "Lid closed, staying awake" (the banner needs notifications allowed).
To remove it, turn the switch off and click Remove Helper. Glowmoth is part of MacSuite and you can try it free for 7 days; see the Glowmoth page and the closed-lid docs.
Other keep-awake apps and the lid
As of November 2026, from each project's public pages:
- Caffeine (iannuttall, open source): closed-lid mode is best-effort. It doesn't change
pmsetor promise every Mac works with the lid closed. - Amphetamine: it has a closed-display mode. The free Amphetamine Enhancer adds a fail-safe that returns the Mac to sleeping if Amphetamine isn't running. Amphetamine's README says closed-display mode may fail after plugging or unplugging power on Apple silicon; the official fix is a separate manual "Power Protect" install with a script and a sudoers file.
For a wider comparison, see Best Keep-Awake Apps for Mac.
If the Mac still sleeps with the lid closed
| Symptom | Cause | Fix |
|---|---|---|
Only ran caffeinate or a normal session | Lid sleep isn't blocked by assertions | Use one of the three methods |
| Mode on, panel says "Sleep Allowed" | No session or reason is active | Start a session |
| Icon has a slash, panel says "Paused" | Battery or heat limit tripped | Plug in or let the Mac cool |
| Caption: "Allow the Glowmoth helper in Login Items to finish." | Helper not approved | Approve it in Login Items |
| Caption: "macOS couldn't install the helper…" | Install failed | Move Glowmoth to Applications, retry |
| Caption: "Can't reach the helper…" | Helper connection lost | Turn the mode off and on |
| Caption: "Sleep is already turned off with pmset, outside Glowmoth." | You set pmset yourself | Run sudo pmset -a disablesleep 0, then let Glowmoth manage it |
| "Your trial has ended…" | No valid license | Enter a MacSuite license |
Two more cases. In Show More, the panel lists "Closing the lid sleeps this Mac unless it has power and an external display." Glowmoth shows that on every laptop, even with the mode on; it's a known quirk, not a failure. And if the Mac stayed awake but the connection dropped, note that Glowmoth doesn't keep Wi-Fi or VPN alive or fix captive portals.
Checklist before you try again
- Closed-lid mode is on and the caption says "Active".
- The helper is allowed in Login Items.
- A session or automatic reason is running (panel title "Awake").
- The panel isn't "Paused" for battery or heat.
- You haven't set
pmsetmanually. - The trial or license is valid.
If nothing works
Contact us through macsuite.app/support. Include the closed-lid caption text, your macOS version, the Mac model, and what you already tried. More fixes are in Troubleshooting Glowmoth and Mac Won't Sleep? Find What's Keeping It Awake.
Closed-lid mode in Glowmoth 1.0.0 isn't keeping my MacBook awake.
Mac model and macOS version:
Caption under "Stay awake with the lid closed":
Panel title during the session (Awake / Paused):
Helper allowed in Login Items: yes/no
Steps already tried: restarted mode, removed and reinstalled helperCommon questions
Does caffeinate -s keep a MacBook awake with the lid closed?
On AC power it's the flag aimed at that case, but we haven't verified it on every macOS version. On battery it does nothing, so it doesn't solve the battery problem here.
Is it safe to leave a MacBook running with the lid closed?
Keep it out of bags and sleeves, because a running Mac gives off heat. Glowmoth's heat cut-off pauses it under serious thermal pressure, but that's no reason to bag a running Mac.
Does this work on a Mac mini or iMac?
Closed-lid mode is laptop-only. Desktop Macs have no lid, so a normal session is enough. See How to Stop Your Mac From Going to Sleep.
How do I undo pmset if I forget?
Run sudo pmset -a disablesleep 0, then check with pmset -g | grep -i sleepdisabled.