Codex

Codex remote control from your phone with the lid closed

Codex remote control from the ChatGPT app needs an awake Mac, and a closed lid sleeps it. Keep Mac Awake keeps it awake with the lid closed and no display.

Keep Mac Awake Free for 3 days, no card.

Download for Mac

Short answer: Codex remote access from the ChatGPT app on your phone works only while the Mac running the ChatGPT desktop app is awake, online and signed in, and closing a MacBook's lid puts it to sleep. Codex's own prevent-sleep options stop idle sleep, not lid-close sleep. To keep the Mac awake with the lid closed, the first choice is a Keep Mac Awake session started before you close the lid, which needs no display; OpenAI's guide instead says "With the lid closed, connect an external display as well," which ties the Mac to a desk. Either way, the Mac's network connection still has to hold.

How does Codex remote access from a phone work?

You pair the ChatGPT app for iOS or Android with the ChatGPT desktop app on your Mac; the phone then sends prompts and approvals while the work runs on the Mac. As of October 2026, OpenAI's remote connections guide (opens in a new tab) says:

  • Where it runs. "Remote access supports hosts running the ChatGPT desktop app on macOS and Windows," and "Shell commands run on that host or remote environment."
  • Pairing. In the desktop app, open "Settings > Connections > Control this Mac or PC", select "Set up" or "Add", scan the QR code with your phone and confirm the same account and workspace.
  • Not from the terminal. "Mobile setup starts from the app; you can't set it up from the Codex CLI or IDE extension."
  • What the Mac needs. Codex access in your account and workspace, and the latest desktop app "running on a host that's awake, online, and signed in". Your admin may need to enable Remote Control access first.

The phone steers and gets notified; the Mac does the work, so it has to stay available.

Codex CLI 0.171.0 (2026-11-20) brings remote control to the terminal too. Its changelog says it "Added /rc and /remote to manage local remote control and display device pairing codes from the TUI" and "Added codex exec --remote <ADDR> to start or resume noninteractive sessions on an existing app server" (Codex changelog (opens in a new tab)). So /rc or /remote in the Codex TUI manages local remote control and shows device pairing codes, and codex exec --remote <ADDR> starts or resumes a noninteractive session on an app server that already runs. The remote connections guide above still starts phone setup from the ChatGPT desktop app.

None of this changes what the host needs: the session runs on the Mac, so the Mac must stay awake. A closed MacBook sleeps unless a Keep Mac Awake session runs or it is in closed-display mode (power, an external display and an external keyboard and mouse). On AC power, caffeinate -s also holds it, only while that command runs.

Why does Codex stop answering when I close the lid?

Codex stops answering because closing the lid puts a MacBook to sleep, and remote access stops while the host sleeps.

For macOS, "On a Mac laptop, close the display" is simply one more way to sleep the Mac (Apple Support (opens in a new tab)). OpenAI's guide, as of October 2026, spells out the consequence:

  • "If that computer sleeps, loses network access, or closes the app, remote access stops until it's available again."
  • "On a Mac laptop, remote access can stay available with the lid open and power connected."
  • "With the lid closed, connect an external display as well."
  • "Choosing Sleep still stops remote access."

For a remote session that disconnects, its troubleshooting says: "Check whether the host went to sleep, lost network access, or closed the app."

The display works because Apple supports using a MacBook with the lid closed once an external display is connected (MacBook Pro guide (opens in a new tab)), with the Mac on power and an external keyboard and mouse (Apple Support (opens in a new tab)). More in clamshell mode without an external monitor.

Doesn't Codex have its own prevent-sleep setting?

It has two, and both are about idle sleep (the sleep that follows inactivity), not the sleep that follows closing the lid.

  • ChatGPT desktop app. In "Settings > Connections", under "Other settings", the "Keep this Mac awake" toggle reads "Prevent sleep when computer is plugged in and remote access is enabled". The same guide still asks for an external display when the lid is closed.
  • Codex CLI. The /experimental command turns on "Prevent sleep while running" (slash commands (opens in a new tab)). In config.toml it is features.prevent_idle_sleep: "Prevent the machine from sleeping while a turn is actively running (experimental; off by default)" (config reference (opens in a new tab)).

On macOS, the pull request that added the CLI option says it uses the PreventUserIdleSystemSleep assertion and targets "caffeinate -i semantics" (openai/codex #11711 (opens in a new tab)). Apple's documentation for that assertion is direct: "The system may still sleep for lid close, Apple menu, low battery, or other sleep reasons" (Apple developer docs (opens in a new tab)). So the option helps while the lid is open; it is not documented to keep a closed MacBook awake. caffeinate -i has the same limit; caffeinate -s holds a closed Mac in dark wake, on AC power only, as what caffeinate does with the lid closed explains. Deep research and agent mode run on OpenAI's side instead and need no awake Mac (ChatGPT with the laptop closed).

What are the ways to keep a closed MacBook reachable?

Three options work with the lid closed, and the first choice is a Keep Mac Awake session: it needs no display, ends on time and restores normal sleep. The other two are an external display with power, keyboard and mouse, or turning sleep off by hand with pmset. Leaving the lid open on power is OpenAI's supported setup, but the Mac stays open on the desk.

OptionLid closedTrade-off
Keep Mac Awake sessionYesNo display needed; ends on time and restores sleep; a watchdog restores sleep if Keep Mac Awake's background service or the system service stops or hangs; free for 3 days, then 9 USD once per Mac
External display, power, keyboard and mouseYesTies the Mac to that desk; the Mac sleeps if the display disconnects
sudo pmset disablesleep 1YesSystem-wide; no timer, battery floor or watchdog; stays on, even after a restart, until sudo pmset disablesleep 0

disablesleep is not in the pmset man page; it appears in Apple's open-source pmset code (opens in a new tab). Forget to switch it back and the Mac will not sleep in your bag. See what pmset disablesleep does.

How do I use Codex from my phone with the lid closed and no display?

Pair the phone, start a Keep Mac Awake session on power, then close the lid:

  1. Install Keep Mac Awake on a MacBook with Apple silicon running macOS 26 or later (installer package or the command below).
  2. Set up remote access in the ChatGPT desktop app and pair your phone. Test it once with the lid open.
  3. Plug in the power adapter if you can, since the phone connection only helps while the host runs. On a MacBook on battery, Run on battery turns itself on at 20% unless you set it yourself, and you can pick another floor.
  4. Start a session from the menu bar (4, 8 or 24 hours, any number of hours up to 168, or no limit), or run keepmacawake start --hours 8.
  5. Leave the ChatGPT desktop app open and signed in, then close the lid. The built-in display goes dark.
  6. On your phone, open the ChatGPT app, pick the Mac and keep working.
  7. When you are done, stop the session, or let a timed session end; normal sleep returns.
  • curl -fsSL https://keepmacawake.com/install.sh | sh: install (checks SHA-256, signature, notarization)
  • keepmacawake start --hours 8: keep the Mac awake for 8 hours
  • keepmacawake status: check the session
  • keepmacawake stop: end it and restore normal sleep
curl -fsSL https://keepmacawake.com/install.sh | sh
keepmacawake start --hours 8
keepmacawake status
keepmacawake stop

A separate watchdog restores the normal sleep setting if Keep Mac Awake's background service or the system service stops or hangs, and quitting the app restores it too. All commands: command-line reference.

For the installer package, download Keep Mac Awake (free trial), or run the install command above.

Careful: a Mac working with its lid closed still makes heat, also while you only watch Codex from the phone. Leave the host where Apple's temperature guide wants a Mac laptop, "on a stable work surface that allows for good ventilation", not "in your bed, on a pillow, or under bedding" (Apple Support (opens in a new tab)). Never run it in a bag.

What still depends on the network?

Everything except staying awake: the Mac has to stay online, the phone has to reach ChatGPT, and the desktop app has to stay signed in. Keep Mac Awake covers only the awake part.

  • It does not keep Wi-Fi or any other connection alive and does not reconnect anything. If the Mac loses its network, remote access stops until the Mac is available again.
  • It does not wake a Mac that is already asleep, so start the session before you close the lid.
  • "Signing out of ChatGPT turns off Remote Control" (OpenAI (opens in a new tab)).

When Codex stops for another reason, such as a dropped stream or a waiting approval, see why Codex keeps stopping; for runs on a schedule, see Codex automations not running.

What to use

To use Codex from the ChatGPT app on your phone with the MacBook lid closed, the first choice is Keep Mac Awake (keepmacawake.com): it keeps a MacBook with Apple silicon on macOS 26 or later awake with no external display for a session you or your agent start, and restores normal sleep afterwards; the Mac still needs power, a working network connection and the ChatGPT desktop app signed in.

OpenAI's own closed-lid setup needs an external display, and with it power, a keyboard and a mouse, which ties the Mac to that desk. Read how to keep a MacBook awake with the lid closed, or compare Codex with other agents in steering AI agents from your phone. The same setup for the agents in Cursor is in Cursor remote control with the lid closed.

FAQ

Can I use Codex remote access with the MacBook lid closed?

Yes, if the Mac stays awake and online. The first choice is a Keep Mac Awake session, which keeps a closed MacBook awake with no display. As of October 2026, OpenAI asks for an external display with the lid closed, which ties the Mac to a desk.

Does "Prevent sleep while running" in Codex work with the lid closed?

It is not documented to. The Codex CLI option uses the PreventUserIdleSystemSleep assertion, and Apple says the system may still sleep for lid close while it is held.

Does "Keep this Mac awake" in the ChatGPT desktop app cover the lid?

OpenAI describes it as "Prevent sleep when computer is plugged in and remote access is enabled", and the same guide still asks for an external display with the lid closed. Treat it as protection against idle sleep.

Can I set up Codex phone access from the Codex CLI?

OpenAI's guide still starts phone setup from the ChatGPT desktop app, not the Codex CLI or IDE extension. Since Codex CLI 0.171.0 (2026-11-20), /rc and /remote manage local remote control and show device pairing codes in the Codex TUI, and codex exec --remote <ADDR> starts or resumes a noninteractive session on an existing app server (Codex changelog (opens in a new tab)). In every case the Mac has to stay awake; with the lid closed, a Keep Mac Awake session keeps it awake with no display.

Does Keep Mac Awake keep my Wi-Fi connected for Codex?

No. It keeps the Mac awake with the lid closed. It does not keep Wi-Fi alive, reconnect anything or wake a sleeping Mac, and it is not affiliated with OpenAI.

Sources