---
title: Use Codex from your phone with the MacBook lid closed
description: Codex remote access needs an awake Mac, and closing the lid puts a MacBook to sleep. Use an external display, or Keep Mac Awake with no display.
date: 2026-10-20
kicker: Codex
section: Agents and remote control
related: steer-ai-agents-from-your-phone, keep-claude-code-running-lid-closed, run-ai-agents-overnight-macbook
order: 4
home: 4
---

> **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. Closing a MacBook's lid puts it to sleep, which is why OpenAI says "With the lid closed, connect an external display as well." Codex's own prevent-sleep options stop idle sleep, not lid-close sleep. To skip the display, start a Keep Mac Awake session before you close the lid; 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](https://learn.chatgpt.com/docs/remote-connections) 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.

## 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.

Apple lists "On a Mac laptop, close the display" as a way to put a Mac to sleep ([Apple Support](https://support.apple.com/guide/mac-help/put-your-mac-to-sleep-or-wake-it-mh10330/mac)). 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](https://support.apple.com/guide/macbook-pro/connect-an-external-display-apd8cdd74f57/mac)), with the Mac on power and an external keyboard and mouse ([Apple Support](https://support.apple.com/en-us/102501)). More in [clamshell mode without an external monitor](/blog/clamshell-mode-without-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](https://learn.chatgpt.com/docs/cli/slash-commands)). 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](https://learn.chatgpt.com/docs/config-file/config-reference)).

On macOS, the pull request that added the CLI option says it uses the `PreventUserIdleSystemSleep` assertion and targets "`caffeinate -i` semantics" ([openai/codex #11711](https://github.com/openai/codex/pull/11711)). 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](https://developer.apple.com/documentation/iokit/kiopmassertiontypepreventuseridlesystemsleep)). So the option helps while the lid is open; it is not documented to keep a closed MacBook awake. The same limit applies to `caffeinate`, covered in [why caffeinate stops at the lid](/blog/caffeinate-lid-closed).

## What are the ways to keep a closed MacBook reachable?

Three options work with the lid closed: an external display, turning sleep off by hand with `pmset`, or a Keep Mac Awake session. Leaving the lid open on power is OpenAI's supported setup and needs nothing extra.

| Option | Lid closed | Trade-off |
| --- | --- | --- |
| External display, power, keyboard and mouse | Yes | Free if you own them; ties the Mac to that desk |
| `sudo pmset disablesleep 1` | Yes | Free; system-wide, no timer, stays on until `sudo pmset disablesleep 0` |
| Keep Mac Awake session | Yes | Paid after a 3-day trial; ends on time and restores sleep |

`disablesleep` is not in the `pmset` man page; it appears in Apple's open-source [pmset code](https://github.com/apple-oss-distributions/PowerManagement/blob/d415e45501842834a280930c3eed9186544a67f0/pmset/pmset.m). Forget to switch it back and the Mac will not sleep in your bag. See [what pmset disablesleep does](/blog/pmset-disablesleep).

## 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. Sessions run on AC power by default; battery use is optional, down to a floor you pick.
4. Start a session from the menu bar (no limit, 1 hour, 8 hours or a custom number of hours up to 168), 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.

```sh
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
```

A separate watchdog restores the normal sleep setting if anything stops or hangs, and quitting the app restores it too. All commands: [command-line reference](https://keepmacawake.com/command-line.md).

> **Careful:** a Mac working with its lid closed still makes heat. Apple says to use a Mac laptop "on a stable work surface that allows for good ventilation" and not "in your bed, on a pillow, or under bedding" ([Apple Support](https://support.apple.com/en-us/102336)). 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](https://learn.chatgpt.com/docs/remote-connections)).

## What to use

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

It is free for 3 days (sessions up to 8 hours, no card), then 9 USD once per Mac plus tax. With a monitor, keyboard and mouse on the desk, OpenAI's own setup works without it. Read how to [keep a MacBook awake with the lid closed](/), or compare Codex with other agents in [steering AI agents from your phone](/blog/steer-ai-agents-from-your-phone).

## FAQ

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

Yes, if the Mac stays awake and online. As of October 2026, OpenAI asks for an external display with the lid closed; a Keep Mac Awake session keeps the Mac awake instead.

### 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?

No. As of October 2026, mobile setup starts from the ChatGPT desktop app, not the Codex CLI or IDE extension.

### 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

- [OpenAI: Remote connections](https://learn.chatgpt.com/docs/remote-connections)
- [OpenAI: Codex CLI slash commands](https://learn.chatgpt.com/docs/cli/slash-commands)
- [OpenAI: Codex configuration reference](https://learn.chatgpt.com/docs/config-file/config-reference)
- [openai/codex pull request #11711](https://github.com/openai/codex/pull/11711)
- [Apple developer docs: kIOPMAssertionTypePreventUserIdleSystemSleep](https://developer.apple.com/documentation/iokit/kiopmassertiontypepreventuseridlesystemsleep)
- [Apple Support: Put your Mac to sleep or wake it](https://support.apple.com/guide/mac-help/put-your-mac-to-sleep-or-wake-it-mh10330/mac)
- [Apple Support: Connect an external display to MacBook Pro](https://support.apple.com/guide/macbook-pro/connect-an-external-display-apd8cdd74f57/mac)
- [Apple Support: If your external display is dark](https://support.apple.com/en-us/102501)
- [Apple Support: Mac laptop operating temperatures](https://support.apple.com/en-us/102336)
- [Apple open source: pmset.m](https://github.com/apple-oss-distributions/PowerManagement/blob/d415e45501842834a280930c3eed9186544a67f0/pmset/pmset.m)
- [Keep Mac Awake command-line reference](https://keepmacawake.com/command-line.md)
