codex remote-control reuses persisted enrollment with stale server_name, causing silent WebSocket disconnect
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.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗