How to keep a Mac awake with the lid closed

Closing a MacBook lid normally triggers sleep. A regular keep-awake command handles idle sleep, but lid-close sleep is a separate path.

Short answer: use clamshell mode with an external display, or use a utility that explicitly supports closed-lid wakefulness. The built-in caffeinate command prevents idle sleep but does not, by itself, override a lid closure.

Why closing the lid is different

macOS distinguishes idle sleep from forced sleep. Apple's power-management documentation lists closing a laptop lid as forced sleep, while idle sleep happens after the computer has been unused for a configured period. Ordinary power assertions can prevent idle sleep. Apple says they cannot prevent forced sleep through the documented API.

Apple's archived power-management Q&A explains the distinction directly. Apple's current Mac User Guide also describes sleep as the normal energy-saving state when you are not using the Mac.

Your options

1. Use Apple's supported clamshell setup

A MacBook can operate closed when connected to the right external display, power, keyboard, and pointing-device setup. This is the safest supported route if you are working at a desk and want the Mac to behave like a desktop.

2. Use caffeinate for idle sleep

For an open MacBook, Terminal's built-in command is often enough:

caffeinate -i

That creates an idle-system-sleep assertion until you stop the command. It is useful during downloads, builds, and terminal work. It does not change what a lid closure means.

3. Use a closed-lid utility

Caffeine Toggle adds one native macOS menu-bar mug. When the mug is full, it starts sleep-prevention assertions and applies a low-level clamshell override. When the mug is empty, it restores normal lid-close sleep.

Heat warning: never put an awake, closed MacBook in a backpack, sleeve, bed, or enclosed space. A build, local model, render, or AI agent can keep the CPU and GPU busy after the display goes dark.

Check that work is still running

  1. Start a visible test job, such as a timer that writes one line to a file every few seconds.
  2. Turn on your chosen keep-awake method.
  3. Place the MacBook on a hard, ventilated surface.
  4. Close the lid for a minute.
  5. Open it and confirm the timestamps advanced without a gap.

A software assertion or successful API return is useful evidence, but a physical lid-close test is the final check for your particular Mac and macOS version.

What about battery and network connections?

Staying awake consumes more battery than sleeping. Plug into power for long jobs when possible. The Mac can keep its local processes alive, but a remote service can still disconnect, time out, or finish independently. Keeping the computer awake does not remove server-side limits.

Which method should you use?

NeedBest fit
Open Mac, temporary terminal jobcaffeinate -i
Closed Mac at a desk with monitorApple-supported clamshell setup
Closed Mac, no external monitorA closed-lid utility plus careful thermal monitoring
One-click visual stateCaffeine Toggle in the menu bar

Put the mug in your menu bar.

Download the ZIP, open it, and drag Caffeine Toggle into Applications. On first launch, Control-click the app and choose Open; if blocked, use System Settings → Privacy & Security → Open Anyway. This build is signed with an Apple Development certificate and is not yet notarized.

Download Caffeine Toggle 3.0.1