codex - 💡(How to fix) Fix codex remote-control reuses persisted enrollment with stale server_name, causing silent WebSocket disconnect

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

The remote_control_enrollments table in state_5.sqlite contained a stale enrollment from a previous run with a different hostname (DESKTOP-NQ78JBR, the Windows host). The CLI reuses this persisted enrollment regardless of whether server_name matches the current machine. The OpenAI relay server detects the mismatch and silently closes the WebSocket after ~10 seconds.

Fix Action

Workaround

codex remote-control stop
sqlite3 ~/.codex/state_5.sqlite \
  "DELETE FROM remote_control_enrollments WHERE server_name != \"$(hostname)\";"
codex remote-control start

Code Example

reusing persisted remote control enrollment: server_name=DESKTOP-NQ78JBR
status changed: ConnectingConnected
...~10 seconds later...
remote control websocket writer was stopped
remote control websocket reader was stopped
transport event receiver dropped: connection_closed

---

codex remote-control stop
sqlite3 ~/.codex/state_5.sqlite \
  "DELETE FROM remote_control_enrollments WHERE server_name != \"$(hostname)\";"
codex remote-control start
RAW_BUFFERClick to expand / collapse

Environment

  • Codex CLI v0.135.0-alpha.1
  • WSL2 (Ubuntu 26.04) on Windows 11
  • Standalone install via npm

Symptom

codex remote-control start reports the host is available (e.g. luyh7-wsl), but codex remote-control shows connection is errored. The host never appears in the ChatGPT mobile app device list.

Root Cause

The remote_control_enrollments table in state_5.sqlite contained a stale enrollment from a previous run with a different hostname (DESKTOP-NQ78JBR, the Windows host). The CLI reuses this persisted enrollment regardless of whether server_name matches the current machine. The OpenAI relay server detects the mismatch and silently closes the WebSocket after ~10 seconds.

Log Evidence (RUST_LOG=debug)

reusing persisted remote control enrollment: server_name=DESKTOP-NQ78JBR
status changed: Connecting → Connected
...~10 seconds later...
remote control websocket writer was stopped
remote control websocket reader was stopped
transport event receiver dropped: connection_closed

After deleting the stale enrollment, a fresh one is created with the correct hostname (luyh7-wsl), and codex-backend successfully connects back via the Unix socket — no disconnect occurs.

Workaround

codex remote-control stop
sqlite3 ~/.codex/state_5.sqlite \
  "DELETE FROM remote_control_enrollments WHERE server_name != \"$(hostname)\";"
codex remote-control start

Suggested Fix

Before reusing a persisted enrollment, validate that server_name matches the current hostname. If it does not match, discard the stale record and create a fresh enrollment.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix codex remote-control reuses persisted enrollment with stale server_name, causing silent WebSocket disconnect