Codex in the ChatGPT phone app, SSH with tmux, and third-party mobile clients all reach a Codex session that runs on your Mac. A closed MacBook lid sleeps the Mac, and the phone loses the session until the lid opens. To keep it reachable lid-closed, keep the Mac awake: an external display, a desktop Mac, or Clamshell, a Mac menu bar app that needs no sudo and no monitor.
Clamshell for Mac keeps the Mac awake and online with the lid closed while armed, so your phone can keep reaching Codex. Free for 7 days, then $9.99 once.
Download free trialApple Silicon, macOS 14+. Notarized by Apple. 3.6 MB. Or buy now, $9.99. On your phone? Send the Mac download link to yourself.
OpenAI does ship a phone remote for Codex: the ChatGPT mobile app can control Codex chats on a paired Mac. Developers also use SSH and tmux, often over Tailscale, or open-source clients such as Happy. All of these send your instructions to a Codex session that runs on the Mac. None of them keeps the Mac awake when the lid closes. This guide covers the remote routes and the free and paid ways to keep a closed MacBook reachable. If you only need a long local run to finish, start with keep Codex running with the lid closed.
Can you control a local Codex session from your phone?
Yes. There is one official route and a few common do-it-yourself ones. They differ in setup and security. They all share one dependency: the Mac.
| Route | How it connects | Lid closed, no monitor |
|---|---|---|
| Codex in the ChatGPT phone app | Pair the phone with the ChatGPT desktop app by QR code. OpenAI uses a secure relay, so no port is opened on the Mac. | Stops until the Mac wakes |
codex remote-control (CLI) |
Marked experimental in the Codex CLI help. Starts a background app server with remote control; pair prints a short-lived pairing code. |
Stops, same host requirement |
| SSH and tmux | macOS Remote Login, reached through Tailscale or another VPN, from an SSH app such as Termius or Blink. | Freezes; tmux reattaches after wake |
| Third-party clients | Open-source apps such as Happy, HAPI or Remodex run their own daemon on the Mac. | Stops; some also check the lid |
| Codex Cloud | Not your Mac: each task gets an OpenAI cloud workspace you can follow from the phone. | Keeps going |
The official route. On the Mac, open the ChatGPT desktop app and go to Settings > Connections > Control this Mac or PC, choose Set up or Add, and scan the QR code with your phone. In the ChatGPT app on iOS, open Codex, or Remote if your app still shows it. From the phone you can start or continue chats, approve commands, and review diffs and test results. OpenAI's docs say the Codex CLI and IDE extension cannot start this mobile setup, so you need the desktop app on the Mac.
The CLI route. Recent Codex CLI releases include codex remote-control, with start, stop and pair subcommands. Its own help text labels it experimental, and OpenAI's Remote connections page does not document it, so expect it to change.
What happens when the lid closes
Closing a MacBook lid starts lid sleep, which is separate from idle sleep. A busy Codex session does not block it, and caffeinate does not either, because it only holds off idle sleep. Once the Mac sleeps, every route in the table above loses its far end:
- Codex in the ChatGPT app. OpenAI's Remote connections docs say that if the computer sleeps, loses network access or closes the app, remote access stops until it is available again. They say a Mac laptop stays available with the lid open and power connected, and that with the lid closed you should also connect an external display.
- SSH. The connection from your phone stops responding and eventually times out. The tmux session is still there after the Mac wakes, frozen at the moment the lid closed.
- Codex itself. The CLI or app session stops mid-turn. An open report, openai/codex issue #34358, describes the CLI staying stuck on reasoning after a lid close, so plan for a retry after wake.
The desktop app's Keep this Mac awake setting does not close this gap. OpenAI describes it as preventing sleep when the computer is plugged in and remote access is enabled, which covers idle sleep with the lid open. Why Keep this Mac awake stops at a closed lid goes into the details.
Ways to keep a local Codex session reachable
Use a Mac mini or another desktop Mac
No lid to close. Set it not to sleep in System Settings and use it as the Codex host for your phone. The best always-on answer if you have one or plan to buy one.
Connect an external display
OpenAI's documented setup for a closed laptop. Apple's closed-display mode also needs power and an external keyboard and mouse. Good at a desk, not on the move.
Send the task to Codex Cloud
OpenAI says each cloud task can keep working while your computer is asleep, and you can follow it from the phone. It cannot use files, tools or credentials that exist only on your Mac.
Leave the lid open on power
Free and supported by OpenAI's docs with Keep this Mac awake on. Fine on a desk at home, less so on a shared table or in a bag.
caffeinate
Does not help here. It blocks idle sleep only, so the Mac still sleeps at lid close. See why caffeinate does not work with the lid closed.
sudo pmset -a disablesleep 1
Works with the lid closed, but it is a global admin switch with no timer, active on battery too, and easy to forget. See what pmset disablesleep does and how to undo it.
Clamshell
A menu bar app that keeps an Apple Silicon MacBook awake with the lid closed only while armed, with the built-in display dark. No sudo, no monitor. It watches heat and disarms toward normal sleep at serious thermal pressure.
Clamshell for Mac keeps a closed MacBook awake and online, so Codex stays reachable from your phone. Free for 7 days, then $9.99 once for one Mac.
Download free trialApple Silicon, macOS 14+. Notarized by Apple. 3.6 MB.
Set up Codex on your phone with the lid closed
Use an Apple Silicon MacBook on macOS 14 or later, on a ventilated surface, preferably on power. OpenAI's docs recommend keeping a remote host plugged in.
- Pair the phone. In the ChatGPT desktop app, go to Settings > Connections > Control this Mac or PC, choose Set up or Add, and scan the QR code with the ChatGPT app on your phone. Use the same account and workspace on both.
- Leave Keep this Mac awake on. It still covers idle sleep while the lid is open and the Mac is plugged in.
- Arm Clamshell. Disconnect external displays first: with one connected, Clamshell pauses instead of arming. Arm from the menu bar, 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.
- Check the armed state, then close the lid. Open the Clamshell menu and look for the armed row before the lid goes down. Then pick up the chat on your phone.
The SSH and tmux route
If you prefer a terminal on your phone, or use the Codex CLI only, this is the common setup. It does not involve OpenAI's relay, so you are responsible for access control.
- Turn on Remote Login. In System Settings, go to General > Sharing and turn on Remote Login. Apple suggests limiting it to specific users and turning it off when you no longer need it.
- Put the Mac and phone on a private network. Tailscale is a common choice. On macOS, Tailscale's own SSH server needs the open-source
tailscaledvariant, so with the App Store or standalone app, use plain Remote Login over the Tailscale address. Do not open SSH to the public internet. - Start Codex inside tmux on the Mac.
tmux new-session -A -s codex codex - Attach from the phone. In an SSH app such as Termius or Blink, connect and reattach to the same session:
ssh you@your-mac tmux attach -t codex - Arm Clamshell before you close the lid. tmux keeps the session through a dropped connection, but only an awake Mac keeps Codex working and answering SSH.
Third-party clients can have their own lid logic. Happy issue #1817, open as of October 2026, reports that its daemon refuses to reconnect while the lid is closed with no external display, even on a Mac that is kept awake. Test your client with the lid closed before you rely on it overnight.
Check it from your phone
A connected indicator in the app is not proof that work is happening. Before a long run, spend two minutes on this.
- With the lid open, ask Codex to run this and approve it:
for i in {1..12}; do date -u '+%H:%M:%S' >> lid-check.txt sleep 10 done - Confirm Clamshell is armed and close the lid.
- After two minutes, from your phone, ask Codex to show
lid-check.txtand print the current time. Pass: twelve timestamps about ten seconds apart and a fresh reply. A gap or no reply means the Mac slept or the connection dropped.
What Clamshell does and does not do here
Keeps the closed Mac awake
On an Apple Silicon MacBook with macOS 14 or later, it keeps the Mac awake and on the network with the lid closed while armed, with the built-in display dark. Opening the lid locks the Mac.
Watches heat
Thermal safety is always on. At serious or critical macOS thermal pressure it disarms toward normal lid sleep and blocks arming until the Mac cools. It does not replace airflow, so keep the Mac out of a bag.
Restores normal sleep
Disarming, quitting or a safety stop returns the Mac to normal lid sleep. Nothing persists across a restart, and no admin rights, kernel extension or privileged helper are involved.
Does not manage Codex
It does not detect Codex, end when a task finishes, wake a Mac that is already asleep, repair a dropped connection or answer approval prompts.
From scripts, open "clamshell://arm" and open "clamshell://disarm" request arming and disarming, and Shortcuts gets Arm, Disarm, Toggle and Status actions. The Codex lid-closed guide has a codex exec wrapper that disarms when the job ends. If Codex uses computer use on the host, see computer use with the lid closed. Clamshell costs $9.99 once for one Mac after a 7-day free trial.
Frequently asked questions
Can I control a local Codex session from my phone?
Yes. OpenAI's Remote connections feature lets the ChatGPT mobile app on iOS or Android control Codex on a paired Mac or Windows PC that runs the ChatGPT desktop app. On iOS you open Codex, or Remote in older app versions. The work still runs on the computer, so it has to stay awake and online.
Does Codex Remote keep working when I close my MacBook lid?
Not by default. Closing the lid puts the Mac to sleep, and OpenAI's docs say remote access stops until the computer is available again. OpenAI says a Mac laptop host stays available with the lid open and power connected, and that with the lid closed you should connect an external display. Without a display, a lid-sleep tool such as Clamshell can keep the Mac awake.
Does SSH and tmux keep Codex running when the Mac sleeps?
No. tmux keeps the terminal session alive across a dropped SSH connection, but it cannot run anything while the Mac is asleep. The SSH connection from your phone stops responding, Codex stops making progress, and you can reattach to the same tmux session after the Mac wakes.
Does caffeinate keep a Mac reachable from my phone with the lid closed?
No. caffeinate prevents idle sleep only. Closing the lid triggers a separate sleep path that caffeinate does not block, so the Mac still sleeps and drops off the network.
Do I need my Mac awake to check Codex Cloud tasks from my phone?
No. Codex Cloud tasks run in OpenAI's cloud, and OpenAI says each task can keep working while your computer is asleep. You can follow them in the ChatGPT mobile app. Cloud tasks cannot use files, tools or credentials that exist only on your Mac.
Does Clamshell make a sleeping Mac reachable or detect Codex?
No. Clamshell keeps an Apple Silicon MacBook awake with the lid closed while it is armed, which keeps the Mac on the network. It cannot wake a Mac that is already asleep, repair a dropped connection, detect Codex or answer Codex approval prompts.
Related guides
- Keep Codex running when you close your MacBook lid
- Why Codex "Keep this Mac awake" stops at a closed lid
- Use a MacBook as a home server with the lid closed
- Run AI coding agents overnight on a MacBook
- Why caffeinate does not work with the lid closed
- Is it safe to run a MacBook with the lid closed?
Sources checked October 9, 2026: OpenAI's Remote connections, Codex on mobile and Codex Cloud docs, the openai/codex source and issue #34358, Happy issue #1817, Tailscale's Tailscale SSH docs, and Apple's Remote Login and closed-display guidance. Clamshell behavior is described from its app source and FAQ. No new hardware testing was done for this page. Clamshell is an independent app, not affiliated with or endorsed by OpenAI. Codex and ChatGPT are trademarks of their owner.