How to keep a MacBook awake with the lid closed.

By Matyas Rathonyi. Updated September 29, 2026. Guides

A MacBook sleeps when you close the lid unless macOS sees an allowed external display setup, or something overrides lid sleep.

Two routesA display attached, or a lid override
Free: pmsetSystem-wide, on until you undo it
Not caffeinateIt does not survive a lid close
$9.99 onceClamshell, no admin, after a 7-day trial

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 trial
Two closed MacBooks. The left one stays awake because an external display is attached by a cable. The right one has no display and stays awake because lid sleep is overridden. Display attached Apple's rule Lid overridden no monitor
Two ways past lid sleep.Every working method either satisfies Apple's external display rule or changes what the lid does. Without a monitor, only the second kind helps.

With a monitor, keyboard, and mouse, use Apple's closed-display setup. Without a monitor, your options are an HDMI dummy plug, sudo pmset disablesleep, Amphetamine's Closed-Display Mode, LidRun Pro, or Clamshell for Mac, a menu bar app that keeps an Apple Silicon MacBook running with the lid closed and needs no admin rights. caffeinate on its own does not survive a lid close.

Quick answer

At a desk with a monitor

Connect and allow an external display, keyboard, and mouse, then close the lid. This is Apple's supported route and costs nothing if you own the hardware.

No monitor, Terminal only

sudo pmset -a disablesleep 1 works, but it is system-wide and stays on until you run sudo pmset -a disablesleep 0.

No monitor, free or agent-aware app

Amphetamine's Closed-Display Mode is free; on Apple Silicon laptops its App Store listing describes a separate Power Protect download. LidRun Pro is agent-aware, from $9.90 once; its free tier is lid-open only.

No monitor and no admin

Clamshell restores normal lid sleep on lid open after an Option-close, and needs no sudo, admin prompt, or privileged helper. 7-day free trial, then $9.99 once for one Mac.

Does not work lid-closed: caffeinate, and keep-awake apps that only block idle sleep, such as KeepingYouAwake.

Why closing the lid is different from idle sleep

macOS has two separate reasons to sleep. Idle sleep happens when nobody touches the Mac for a while, and a running process can hold it off with a power assertion. That is what caffeinate and most keep-awake apps do. Lid-close sleep is a separate policy triggered by the lid itself. An active download, build, or AI coding agent does not block it. Unless an external display setup or a lid-sleep override is in place, the Mac goes to sleep a moment after the lid shuts and local work stops. The caffeinate guide explains the difference in more detail.

So every working method below does one of two things: it satisfies Apple's external display rule, or it changes what the lid does.

Every method, side by side

MethodLid closedHardwareAdminHow it endsPrice
Apple external display setup Yes External display, keyboard, and mouse No Disconnect the display or open the lid Free if you own the hardware
HDMI dummy plug Yes, by posing as a display The plug, plus a free port No Unplug it Cost of the adapter
caffeinate No None No When the process or timer ends Free, built in
pmset disablesleep Yes None Yes, sudo Only when you run the inverse command Free, built in
Amphetamine Yes, with Closed-Display Mode None; Apple Silicon laptops get an optional Power Protect install for power changes App: no. Optional Power Protect install asks for Touch ID or an admin password When the session ends Free
LidRun Yes, with Pro None Helper approval once, or an admin password per toggle When the job ends, a guardrail trips, or you stop it Free lid-open tier; Pro from $9.90 once

Route 1: Apple's external display setup

If you already work at a desk with a monitor, this is the least surprising choice. Apple's support article on accessories says to allow an external display, a mouse, and a keyboard to connect to your Mac laptop; after that you can use it with the lid closed.

  1. Connect the external display, keyboard, and mouse, and allow them if macOS asks.
  2. Wait until the desktop appears on the external display.
  3. Close the lid. The Mac keeps running on the external display.

It does not help on a train, in a bag, or for a Mac you want to leave running headless. An HDMI dummy plug imitates a monitor to cover that case, but it is one more piece of hardware to carry, it takes a port, and macOS treats the phantom screen as real, so windows can open where you cannot see them. The clamshell mode without an external display guide covers the dummy plug route.

Route 2: pmset disablesleep in Terminal

This is the free, no-install override. It sets a system-wide SleepDisabled flag, so the Mac stays awake with the lid closed, on battery and on power.

# keep awake, including lid closed
sudo pmset -a disablesleep 1

# check: look for SleepDisabled 1
pmset -g

# restore normal sleep
sudo pmset -a disablesleep 0

The catch is scope. The flag is not tied to a job, it has no timer, nothing shows it in the menu bar, and it is not in the current pmset(1) manual. The pmset disablesleep guide has the checks and the undo steps.

It has no timer. Forget to undo it and a closed MacBook keeps running in a bag until the battery is empty.

Route 3: Clamshell for Mac

Clamshell does one job: while armed, closing the lid leaves the Mac running with the built-in display black. It uses the unprivileged IOKit clamshell sleep-state control on the system power domain plus an idle-sleep assertion, not pmset disablesleep, so there is no sudo, admin prompt, kernel extension, driver, or privileged helper.

  1. Download Clamshell from clamshell.dev and open it. It lives in the menu bar.
  2. Disconnect external displays for a no-monitor session. Clamshell pauses, and does not arm, while an external display is connected.
  3. Hold ⌥ Option while closing the lid. This gesture needs a lid angle sensor: MacBook Air M2 (2022) or later, or 14-inch or 16-inch MacBook Pro (2021) or later. On other Apple Silicon MacBooks, arm from the menu bar icon instead.
  4. Open the lid when you are back. The Mac locks, and an Option-close session ends. A session armed from the menu or a URL stays armed until you disarm it.

The setting is never saved across a restart, so restarting always brings back normal lid sleep. It works on power and on battery and re-applies on every plug or unplug. Thermal safety is always on: if macOS reports serious or critical thermal pressure, Clamshell disarms toward normal lid sleep and blocks arming until the Mac cools. An optional low-battery switch, off by default, lets the Mac sleep below a charge level you choose.

Close the lid without a monitor. Clamshell is free for 7 days, then $9.99 once for one Mac. Apple Silicon MacBooks on macOS 14 or later.

Download free trial

Route 4: Amphetamine or LidRun

Amphetamine is a free, long-running keep-awake app on the Mac App Store. Its keep-awake session options include allowing or preventing system sleep when the built-in display is closed. Its listing says Power Protect is only needed on Apple Silicon laptops and is a separate download and installation. The latest version on the listing, checked September 29, 2026, is 5.3.2 from November 10, 2023. If you also want timers and triggers for everyday keep-awake use, it is the strongest free pick. See Amphetamine alternatives for closed-lid use for the details.

LidRun is a menu bar utility focused on AI and developer jobs. Closed-Lid Mode is a Pro feature; its FAQ says it calls pmset disablesleep and uses a helper that you approve once, or macOS asks for an administrator password each time. Its standout is Auto Mode, which detects tools such as Claude Code, Cursor, Docker, and Ollama. The full three-way breakdown is in LidRun vs Amphetamine vs Clamshell.

Which route fits your situation

Running AI coding agents with the lid closed

The most common reason people search for this is a Claude Code or Codex run that should not stop when the MacBook closes. Keeping the Mac awake is only half of it; the agent also needs its permissions and a working network connection. Clamshell does not detect agents on its own. You can arm it from a script with open "clamshell://arm" and disarm with open "clamshell://disarm", or use its Arm, Disarm, Toggle, and Status actions in Shortcuts. The Claude Code lid-closed guide walks through a full overnight setup.

Keep a closed MacBook safe

Frequently asked questions

Can a MacBook stay awake with the lid closed without an external monitor?

Yes. Without a monitor you need something that overrides lid sleep: sudo pmset -a disablesleep 1, an HDMI dummy plug, Amphetamine's Closed-Display Mode, LidRun Pro, or Clamshell for Mac. Stock macOS settings alone cannot do it.

Does caffeinate keep a Mac awake with the lid closed?

No. caffeinate prevents idle sleep. Closing the lid triggers a different sleep path that it does not block, so the Mac still sleeps.

Is there a setting in System Settings to keep a MacBook on when the lid is closed?

Not for a MacBook with no external display. System Settings controls idle and display sleep, not lid-close sleep. Apple's supported route is an external display, keyboard, and mouse.

Is it safe to keep a MacBook running with the lid closed?

Generally yes, with airflow. A closed MacBook on a hard surface can run normal work. Avoid bags and soft furniture, and prefer a tool with a clear off switch. Clamshell disarms toward normal lid sleep on serious or critical thermal pressure.

Does keeping the lid closed drain the battery?

The Mac draws what the work demands, as it would with the lid open. The built-in display stays off, so an idle closed Mac uses little. Heavy work on battery still drains it, so plug in for long runs or set a low-battery cut-off where your tool offers one.

Which method works on Apple Silicon MacBooks?

All of the working methods here run on Apple Silicon. Amphetamine offers an optional Power Protect install on Apple Silicon laptops for power changes, and Clamshell supports only Apple Silicon MacBooks on macOS 14 or later.

Related guides

Sources checked September 29, 2026: Apple's accessory and closed-lid guidance, the Amphetamine App Store listing, LidRun pricing and LidRun FAQ, the KeepingYouAwake README, and the macOS caffeinate(8) and pmset(1) manuals. Clamshell details come from its own documentation. Clamshell is the publisher of this guide. Product names belong to their respective owners.