How to keep a Mac awake with the lid closed (with or without a display)

You can keep a Mac awake with the lid closed in two ways. If you have power, an external display and a keyboard or mouse plugged in, Apple's own closed-display mode does it for you. With no display or on battery, you have to switch system sleep off, either with the undocumented sudo pmset -a disablesleep 1 command (and remember to undo it) or with an app like Liddy that does this for you and switches it back off.
Last updated: 22 November 2026

I close my MacBook lid all the time while something is still running: a long build, a big download, an AI coding agent working through a task list, a backup to a NAS. By default macOS treats a closed lid as "go to sleep now", and most of the "keep awake" advice online only covers the lid-open case. This guide covers every option I know that actually works with the lid shut, when each one makes sense, and how to put things back the way they were.
Why does a MacBook sleep when you close the lid?
Closing the lid is a sleep trigger in its own right. It is handled separately from the idle timers you set in System Settings, so turning off "sleep when idle" does nothing for the lid.
That is also why most keep-awake tools stop working the moment you shut the lid. caffeinate, for example, creates "assertions to alter system sleep behavior" according to its manual page[1]. Its default and -i assertions prevent idle sleep. The -s flag prevents system sleep but, in Apple's words, it is "valid only when system is running on AC power"[1]. None of these is a switch for the lid.
The KeepingYouAwake project, which wraps caffeinate, states plainly in its README that it only prevents sleep on desktop Macs and portable Macs with an open lid[2]. That is an honest summary of the limitation.
So, with the lid closed, you have three real routes:
- Apple's supported closed-display (clamshell) mode.
- Switching system sleep off with
pmset disablesleep. - An app that manages a closed-lid mode for you.
Which option should I use?
| Situation | Best option | Works on battery? | Needs a display? |
|---|---|---|---|
| Desk setup with monitor, keyboard, mouse, charger | Apple closed-display mode | Apple says connect power | Yes |
| Lid closed, no monitor, on the charger | pmset disablesleep or Liddy |
n/a | No |
| Lid closed, no monitor, on battery (bag, car, train) | pmset disablesleep or Liddy |
Yes | No |
| Lid open, just stop idle sleep | caffeinate, System Settings, any keep-awake app |
Yes | No |
If you only need the lid open case, read how to stop a Mac from sleeping or the caffeinate command guide instead. The rest of this post is about the closed lid.
How do I use Apple's closed-display mode?
This is the official, supported way. Apple's MacBook Pro and MacBook Air user guides both say that after you connect a display, you can close the lid and keep using the Mac with connected accessories, and that with an external display and accessories (like a keyboard and mouse) connected, you can keep working with the lid closed[3][4]. Apple's troubleshooting article adds that a closed Mac laptop driving an external display should be connected to power and using an external keyboard and mouse[5].
Steps
- Plug your MacBook into its power adapter.
- Connect the external display and turn it on.
- Connect a keyboard and mouse or trackpad (wired or Bluetooth).
- Close the lid. The Mac keeps running on the external display.
If the display stays dark, Apple suggests checking cables, putting the Mac to sleep and waking it again, or using Option-click on Detect Displays in System Settings > Displays[5].
I wrote a separate guide on MacBook clamshell mode, including running it without an external monitor, if this is your main setup.
The catch
Closed-display mode only works while the display is attached. Unplug the monitor and the Mac goes to sleep. It does nothing for you on a train, in a bag, or on the sofa with the lid shut while a job finishes.
How do I keep a MacBook awake with the lid closed and no display?
You switch off system sleep entirely. macOS has a pmset setting for this, disablesleep, which is not documented in the pmset manual page (I checked: it does not appear in man pmset at all). It is widely used anyway, and it needs admin rights.
Turn it on
sudo pmset -a disablesleep 1
Check it
pmset -g
While it is active, the output includes a SleepDisabled 1 line under the system-wide settings.
Turn it off again
sudo pmset -a disablesleep 0
What to watch out for
- It does not switch itself off. If you forget the second command, your Mac will not sleep at all, lid open or closed, until you run it. That includes in a bag.
- It is undocumented. Apple does not describe it in the manual, so treat it as something that could change between macOS releases.
- It needs
sudoevery time. Fine for a one-off. Annoying if you do it daily. - There is no battery safety net. It will happily run the battery down.
I used this approach for a long time with a sticky note on the laptop that said "undo pmset". That worked about as well as you would expect.
Can an app keep my Mac awake with the lid closed?
Yes, a few can, and the good ones are mostly a safer wrapper around the same idea.
Amphetamine (with Amphetamine Enhancer)
Amphetamine is a free keep-awake app on the Mac App Store. According to the Amphetamine Enhancer project, Amphetamine 5.0 and later has a closed-display mode feature, and the separate Enhancer helper adds a fail-safe for it[6]. The Enhancer exists because Mac App Store apps are sandboxed and limited in what they can do, so it is downloaded separately from GitHub[6]. If you already use Amphetamine, it is worth a look. I compare it with other apps in Amphetamine alternatives for Mac.
Liddy
Full disclosure: Liddy is our app, built at Metamindz. It is a free macOS menu bar app that keeps a MacBook awake with the lid closed, on battery and with no external display.
How it works, in plain terms:
- You approve a small privileged helper once (System Settings > General > Login Items & Extensions > Allow in the Background).
- When you turn Liddy on, the helper runs
pmset -a disablesleep 1. When you turn it off, it runspmset -a disablesleep 0. It only accepts requests from the signed Liddy app. - Normal sleep comes back when Liddy turns off, quits, crashes or the Mac restarts. The helper resets it at boot and whenever the app's connection drops. That is the part the sticky note never managed.
- It also holds a standard IOKit "prevent idle sleep" power assertion while it is on.

The bits I find useful day to day:
- Timer: unlimited, 30 minutes, 1, 2, 4 or 8 hours, or a custom time in 15-minute steps up to 24 hours.
- Battery cut-off: on battery, it turns itself off at a level you choose (default 15%, adjustable from 5 to 50%) and sends a notification.
- Backup Wi-Fi failover: while it is on, it checks real internet access and, after 15 seconds offline, tries your backup networks in order, such as your iPhone hotspot. It cannot switch the hotspot on for you (Apple offers no API for that), so the hotspot needs to be on with "Allow Others to Join" enabled. More on that in getting a Mac to auto-connect to an iPhone hotspot.
- URL commands:
open liddy://onandopen liddy://offwork from Terminal, Shortcuts, Raycast or Alfred, so you can script it.
It needs macOS 14 Sonoma or later and runs on Apple silicon and Intel. It is signed and notarised by Apple. There is no account, subscription or in-app purchase; the download page asks for an email address. You can get Liddy here.
Should I keep my Mac awake on battery or plugged in?
Both work with disablesleep or Liddy. They just carry different risks.
Plugged in is the easy case. The main thing to manage is heat (see below). If you also have a display and keyboard, use Apple's closed-display mode and you do not need anything else.
On battery is where people get caught out. A closed MacBook that cannot sleep will keep using power until the battery is empty. Before you close the lid on battery, I would:
- Set a timer that matches the job, rather than leaving it unlimited.
- Set a battery floor (Liddy's cut-off, or check in on it yourself if you use raw
pmset). - Quit anything heavy you do not need running.
- Save your work, in case the battery does run out.
Is it safe to run a MacBook with the lid closed?
Generally yes, if you are sensible about heat. Apple's guidance on laptop operating temperatures says to use your Mac laptop where the ambient temperature is between 10° and 35° C, on a stable work surface that allows for good ventilation, not in your bed, on a pillow or under bedding, and not to put anything over the keyboard[7].
My own rules for closed-lid running, which follow from that:
- Never in a bag while doing heavy work. A light background task is one thing. A full CPU build in a zipped rucksack is asking for trouble.
- Hard surface, not a duvet. Same as Apple says.
- Not in a parked car. Apple specifically calls this out because temperatures can exceed the safe range[7].
- Check in on long jobs. If the fans have been running hard for ages, open it up and look at Activity Monitor, as Apple suggests[7].
How do I undo it and get normal sleep back?
- Apple closed-display mode: unplug the display or open the lid. Nothing to undo.
pmset disablesleep: runsudo pmset -a disablesleep 0, then checkpmset -gno longer showsSleepDisabled 1.- Amphetamine: end the session in the app.
- Liddy: turn it off from the menu bar or run
open liddy://off. Quitting it, a crash or a restart also restores normal sleep. To uninstall, turn it off, quit it and move it to the Bin; the helper lives inside the app.
What I would do
- At a desk with a monitor: Apple's closed-display mode. It is free, built in and supported.
- A one-off, plugged in, and you are comfortable with Terminal:
sudo pmset -a disablesleep 1, and set a reminder to undo it. - Regularly closing the lid on battery, or running long jobs like overnight AI agents (see running Claude Code with the lid closed): use an app that switches sleep back on for you and watches the battery.
If that last one sounds like you, download Liddy free. It takes about a minute to set up.
Sources
- Apple, caffeinate(8) manual page (run
man caffeinatein Terminal). - KeepingYouAwake README, GitHub: https://github.com/newmarcel/KeepingYouAwake
- Apple Support, Connect an external display to MacBook Pro: https://support.apple.com/guide/macbook-pro/connect-an-external-display-apd8cdd74f57/mac
- Apple Support, Connect an external display to MacBook Air: https://support.apple.com/guide/macbook-air/connect-an-external-display-apd8cdd74f57/mac
- Apple Support, If your external display is dark or low resolution: https://support.apple.com/en-us/102501
- Amphetamine Enhancer README, GitHub: https://github.com/x74353/Amphetamine-Enhancer
- Apple Support, Keep your Mac laptop within acceptable operating temperatures: https://support.apple.com/en-us/102336
Frequently asked questions
Can I keep my MacBook awake with the lid closed without an external monitor?
Yes, but not with Apple's built-in closed-display mode, which needs a display attached. You need to switch off system sleep, either with sudo pmset -a disablesleep 1 (undo with sudo pmset -a disablesleep 0) or with an app such as Liddy that manages this and restores normal sleep when it turns off.
Does caffeinate work with the lid closed?
Not on its own. caffeinate prevents idle sleep, and its -s flag is only valid on AC power according to its manual page. Closing the lid is a separate sleep trigger, so you still need closed-display mode or disablesleep for a shut lid.
Is pmset disablesleep safe?
It works, but it is undocumented in the pmset manual and it does not switch itself off. If you forget to run sudo pmset -a disablesleep 0, your Mac will not sleep at all, including in a bag, so set a reminder or use a tool that resets it automatically.
Will keeping my Mac awake with the lid closed drain the battery?
Yes, on battery the Mac keeps using power until you stop it or the battery runs out. Use a timer, quit heavy apps, and set a battery floor. Liddy, for example, turns itself off at a level you choose (15% by default) when running on battery.
Is it bad for a MacBook to run with the lid closed?
Not if it can stay cool. Apple advises using a Mac laptop on a stable surface with good ventilation, between 10° and 35° C, and not under bedding or in a parked car. Avoid heavy work in a closed bag.
How do I stop my Mac staying awake after closing the lid?
Run sudo pmset -a disablesleep 0 if you used Terminal, and confirm pmset -g no longer shows SleepDisabled 1. If you used an app, turn it off or quit it. Liddy also restores normal sleep if it crashes or the Mac restarts.