Sleep & power

How to keep your MacBook awake with the lid closed

Closing the lid puts a MacBook to sleep, and caffeinate doesn’t reliably change that. There are two ways around it: Apple’s clamshell mode (power plus an external display) or the undocumented pmset disablesleep switch. One is safe by design. The other needs care.

Option 1: clamshell mode (supported by Apple)

Apple calls it closed-display mode. The MacBook keeps running with the lid shut and uses an external display as its screen. Apple’s requirements:

  • A power adapter connected (or a display that charges the Mac over USB-C or Thunderbolt)
  • An external display
  • An external keyboard and mouse or trackpad, wired or Bluetooth

Connect everything, wait for the desktop to appear on the external display, then close the lid. If the external display goes black, press a key or click to wake it. Before unplugging the display, put the Mac to sleep from the Apple menu.

This is the right answer for a desk setup, and it’s what Apple designed for. Heat isn’t a concern: the fans and chassis are built to cope, though a MacBook Air (no fan) will throttle a little sooner under sustained load.

One limit to know: base M1 and M2 MacBooks drive only one external display. Some M3 and later models support a second display only with the lid closed. Check your model’s tech specs.

Option 2: pmset disablesleep (no display needed)

If you want the Mac to keep working with the lid closed and nothing plugged in, for example to let a long build or an AI agent run while you carry it to a meeting, there’s an undocumented pmset setting:

sudo pmset -a disablesleep 1

Check it took effect:

pmset -g | grep -i sleepdisabled
 SleepDisabled		1

And switch it off again when you’re done:

sudo pmset -a disablesleep 0

This works on Apple Silicon MacBooks in current macOS releases, but it is not a supported Apple feature. It isn’t in the pmset man page, and Apple could change it in any update. Test it on your Mac before relying on it.

Read this before you use it

disablesleep turns off sleep completely. Not just for the lid: idle sleep, the Apple menu’s Sleep and low-battery sleep are all affected. That brings real risks:

  • Heat. With the lid shut, a MacBook Pro loses some of its airflow and a MacBook Air loses the surface it radiates heat through. Under a heavy load, expect throttling, and never put a working Mac in a bag or sleeve. A closed bag can get hot enough to damage the battery over time.
  • Battery. On battery, the Mac can keep running until the battery is close to empty. Deep discharges wear it faster.
  • You forget it’s on. The setting survives restarts. A week later your Mac still won’t sleep, and you’re reading why won’t my Mac sleep.

Safer habits:

  • Turn it on only for the job, and switch it off yourself when you open the lid. Don’t chain sudo pmset -a disablesleep 0 after a long command: sudo asks for your password again after a few minutes, so it would sit waiting with sleep still disabled.
  • Keep the Mac on a hard surface, ideally plugged in.
  • Watch temperatures. Our guide to a Mac running hot covers how to read them.

Option 3: an app that wraps it

Amphetamine (free, Mac App Store) has a Closed-Display Mode option for its sessions. Because changing lid behavior needs admin rights, on Apple Silicon laptops it asks you to authenticate for each session, or you can install its optional Power Protect script to skip the prompt. Its advantage over typing pmset yourself is that the session ends on its own, so sleep comes back. See the Amphetamine comparison.

What doesn’t work

  • caffeinate -i or -d. They block idle sleep, not the lid. -s (power adapter only) is sometimes reported to help, but results vary, so don’t trust an overnight job to it.
  • “Prevent automatic sleeping on power adapter when the display is off” in Battery › Options. That covers a dark screen, not a closed lid.
  • Keyboard and mouse jigglers. Closing the lid sleeps the Mac regardless of input.

Where Stat Space fits

Stat Space doesn’t keep a Mac awake with the lid closed: doing it reliably needs a root helper, and we chose not to ship one for this. Its keep-awake timers cover the lid-open case, and the ordinary caffeinate guide covers the commands.

What it does do is tell you when your Mac stayed awake with the lid closed without you meaning it to. Its Awake tab logs every app that held a sleep assertion, and when you open the lid after the Mac was awake for a while, it says which app was responsible, for example “Docker kept your Mac awake for 40 min with the lid closed.” That’s free, and useful the morning after you find a warm MacBook in your bag.

Questions

Does caffeinate keep a Mac awake with the lid closed?

Not reliably. caffeinate -i and -d only block idle sleep, and closing the lid is a direct sleep request. Results with -s, which applies only on power, vary between setups. Use clamshell mode or pmset disablesleep instead.

Can clamshell mode run on battery?

Apple’s requirements for closed-display mode include a power adapter. Some setups keep running briefly after unplugging, but don’t rely on it. Plan for the Mac to sleep when power is removed.

Is it bad for a MacBook to run with the lid closed?

Not in clamshell mode on a desk, which Apple supports. Running hard with the lid closed in a bag or on a bed is the risk: heat builds up, the chip throttles, and the battery drains.

How do I check whether sleep is disabled?

Run pmset -g | grep -i sleepdisabled. SleepDisabled 1 means the Mac won’t sleep at all, lid or no lid. Set it back with sudo pmset -a disablesleep 0.

Get started

Know what your Mac is doing, without adding to it.

Free, no account. Pro is $9.99 once for the first 100 buyers.