Codex Keep this Mac awake not working with the lid closed?

By Matyas Rathonyi. Updated October 5, 2026. Guides

The setting was never meant to cover a closed lid: OpenAI's own docs say a closed MacBook also needs an external display. To keep Codex running lid-closed without a monitor, arm Clamshell for Mac before you close the lid.

Plugged inThe only time the setting applies
Lid closedOpenAI says add a display
No sudoNo monitor or admin rights
$9.99 onceAfter a 7-day free trial

Clamshell for Mac keeps the Mac awake with the lid closed while armed, so Codex keeps working. Free for 7 days.

Download free trial

Apple Silicon, macOS 14+. Notarized by Apple. 3.6 MB. Or buy now, $9.99

A phone keeps sending Codex requests to a MacBook. The lid closes, the Mac stays awake and keeps working.
Remote needs a Mac that stays awake.Closing the lid is the one case the Codex setting leaves to an external display. Clamshell covers it without one.

The Codex desktop app's Keep this Mac awake setting lives under its remote connection settings and exists so the ChatGPT phone app can keep reaching your Mac. It is designed for a lid that stays open. Close the lid without a display attached and the Mac goes to sleep anyway, local Codex work stops making progress, and remote access from your phone stops until the Mac wakes. This guide shows which of three cases you hit and how to fix each one.

Why the Mac still sleeps: three cases

You closed the lid with no display attached

Expected behavior. OpenAI's remote connections docs say a Mac laptop stays available with the lid open and power connected, and that with the lid closed you should connect an external display as well. Lid-close sleep is separate from idle sleep, and the setting does not block it.

The Mac was on battery

OpenAI describes the setting as preventing sleep when the computer is plugged in and remote access is enabled. Unplugged, it does not apply, lid open or closed.

Lid open, plugged in, and it still slept

That matches openai/codex issue #23294, open as of October 2026: a Mac on power with an external monitor slept despite the setting. One commenter posted macOS logs showing Codex briefly releasing its sleep assertion right before the Mac began to sleep.

Codex disconnects on a hotspot with the lid closed

Issue #21703 reports the desktop app's separate Prevent sleep while running setting failing in that setup, also open as of October 2026. Closed-lid sleep is the first thing to rule out.

With only the Codex setting, the job stalls when the lid closes and the Mac sleeps. With Clamshell armed, the job keeps going to the end. z Setting only sleeps at lid close Clamshell armed keeps running
Same Codex task, lid closed, no monitor. The setting holds off idle sleep, but closing the lid takes a different sleep path that it does not block.

Keep Codex running with the lid closed

Use an Apple Silicon MacBook on macOS 14 or later, on a ventilated desk, preferably on power. Leave Keep this Mac awake on: it still covers idle sleep while the lid is open.

  1. Install Clamshell and open it once. It sits in the menu bar. No sudo, admin password, kernel extension or privileged helper is involved.
  2. Disconnect external displays. With a display connected, Clamshell pauses (yellow menu bar icon) instead of arming. It arms automatically once displays disconnect.
  3. Arm it. Choose arm from the menu bar menu, which covers the next close only. Or hold Option while you close the lid, on a MacBook Air M2 (2022) or later or a 14-inch or 16-inch MacBook Pro (2021) or later. Shortcuts and right-click arming stay active across reopenings until you disarm.
  4. Confirm the armed state, then close the lid. Open the menu and look for the Armed row before the lid goes down. A paused state is not armed.
Clamshell switches on and its status turns blue: armed for the next close. Armed for the next close
Arm, look, then close. Check the armed state before the lid goes down. Requests from scripts arrive asynchronously.

If you start Codex jobs from a script, open "clamshell://arm" requests arming and open "clamshell://disarm" ends it. The request is asynchronous, so check the menu bar before closing the lid. The Codex lid-closed guide has a full codex exec wrapper.

What happens while the lid is closed

The built-in display goes black while Codex output keeps arriving. Display black Codex keeps working
Dark panel, live session. The built-in display stays black while the Mac keeps running Codex and stays on the network.

Clamshell does not know about Codex. It does not detect when a task ends, answer approval prompts, or keep a flaky connection alive. Before a long run, do the two-minute timestamp check in the Codex lid-closed guide.

Clamshell keeps your Mac awake with the lid closed. Free for 7 days, then $9.99 once for one Mac. 14-day money-back guarantee.

Download free trial

Other ways to fix it

Connect an external display

OpenAI's documented setup for a closed lid. Apple's closed-display mode needs the Mac on power with an external keyboard and mouse as well. The better fit if you work at a desk with that hardware anyway.

Leave the lid open on power

Free and fully supported by OpenAI's docs: lid open, plugged in, Keep this Mac awake on. Fine at home, less so in a bag or on a shared desk.

Send the task to Codex Cloud

OpenAI says each cloud task has its own workspace and can keep working while your computer is asleep. The best fit when the job does not need your local files, tools or credentials.

Use sudo pmset -a disablesleep 1

Works with the lid closed, but it is a global admin switch with no timer, on battery too. See what pmset disablesleep does and how to undo it.

caffeinate and most keep-awake menu bar apps do not help here: they hold off idle sleep, not lid-close sleep. Why caffeinate does not work with the lid closed explains the difference.

Frequently asked questions

Why does my Mac still sleep with Codex Keep this Mac awake turned on?

The most common reason is a closed lid. OpenAI describes the setting as preventing sleep when the computer is plugged in and remote access is enabled, and its docs say a Mac laptop with the lid closed also needs an external display. On battery the setting does not apply. If the Mac sleeps with the lid open and power connected, that matches an open bug report on the openai/codex GitHub repository.

Does Codex keep running if I close my laptop?

Codex Cloud tasks do, because they run in OpenAI's cloud. Local Codex work in the desktop app or CLI stops making progress when a closed lid puts the Mac to sleep, unless an external display setup, pmset disablesleep, or a lid-sleep tool such as Clamshell for Mac keeps the Mac awake.

Can I keep Codex running with the lid closed without an external display?

Yes. Clamshell for Mac is a menu bar app that keeps an Apple Silicon MacBook awake with the lid closed and the built-in display black, without a monitor, sudo or admin rights. Arm it, confirm the armed state in the menu bar, then close the lid.

Should I turn off Keep this Mac awake if I use Clamshell?

No need. The two do not conflict. Keep this Mac awake covers idle sleep while the lid is open and the Mac is plugged in; Clamshell covers lid-close sleep while it is armed.

Does Clamshell detect Codex or start automatically?

No. Clamshell has no Codex integration and does not detect running agents. You arm it from the menu bar, with Option held while closing the lid on supported models, with Shortcuts actions, or with the clamshell://arm URL.

Will Codex Remote on my phone keep working with the lid closed?

Remote needs the host Mac awake and online. With Clamshell armed the Mac stays awake and on the network with the lid closed, so Remote can keep reaching it. Clamshell does not repair a dropped network connection or answer Codex approval prompts.

Related guides

Sources checked October 5, 2026: OpenAI's Remote connections and Codex Cloud docs, openai/codex issues #23294 and #21703, and Apple's closed-display guidance. Clamshell behavior is described from its changelog and FAQ. Clamshell is an independent app, not affiliated with or endorsed by OpenAI. Codex is a trademark of its owner.