Skip to content

codex remote-control reports "connection is errored" while the app-server remote-control WebSocket is Connected #41549

Closed

Description

@kennetsytn

Bug report: codex remote-control reports "connection is errored" while the app-server remote-control WebSocket is actually Connected

Environment

  • Codex CLI: codex-cli 0.151.0 (standalone install at ~/.codex/packages/standalone/current/codex)
  • App-server: 0.151.0, daemon backend pid
  • macOS: 26.6.2 (Apple Silicon, arm64)
  • Install method: official installer script (curl -fsSL https://chatgpt.com/codex/install.sh | sh)
  • Auth: ChatGPT account (logged in, remote-control feature available on the account)
  • Proxy: local HTTP proxy for outbound access (verified injected into daemon env; codex doctor reports proxy env vars present)

Summary

After enabling remote control, the CLI status command always reports the connection as errored, even though:

  • codex doctor shows a successful WebSocket upgrade (HTTP 101 Switching Protocols),
  • the app-server foreground log shows the remote-control WebSocket transitioning to next_status=Connected,
  • the persisted enrollment is reused and the server token refresh succeeds.

Steps to reproduce

# 1. Install standalone Codex (0.151.0) and log in
curl -fsSL https://chatgpt.com/codex/install.sh | sh

# 2. Start the daemon with remote control enabled
codex remote-control start
# => "Starting app-server daemon with remote control enabled..."
# => "This machine is available for remote control as <hostname>.local."

# 3. Query status
codex remote-control --json

Actual result

Error: Remote control is enabled on <hostname>.local but the connection is errored.

codex remote-control pair also frequently fails:

Error: timed out waiting for remoteControl/pairing/start response

Caused by:
    deadline has elapsed

(It intermittently succeeds — a pairing code was generated once — which suggests the service itself works.)

Expected result

Status should report Connected (or at least a non-errored state) when the WebSocket is up, so pairing and remote control can be used reliably.

Evidence

1. codex remote-control --json while the app-server is running in the foreground with a confirmed Connected WebSocket

Error: Remote control is enabled on <hostname>.local but the connection is errored.

2. App-server foreground log (RUST_LOG trace) — same process, seconds earlier

INFO codex_app_server_transport::transport::remote_control::websocket: connecting to app-server remote control websocket websocket_url=wss://chatgpt.com/backend-api/wham/remote/control/server installation_id=<redacted> server_name=<hostname>.local reconnect_attempt=1 has_enrollment=false server_id=None environment_id=None subscribe_cursor_present=false app_server_client_name=None
INFO codex_app_server_transport::transport::remote_control::enroll: reusing persisted remote control enrollment: websocket_url=wss://chatgpt.com/backend-api/wham/remote/control/server, account_id=<redacted>, app_server_client_name=None, server_id=<redacted>, environment_id=<redacted>
INFO codex_app_server_transport::transport::remote_control::websocket: refreshing remote control server token: websocket_url=wss://chatgpt.com/backend-api/wham/remote/control/server, refresh_url=https://chatgpt.com/backend-api/wham/remote/control/server/refresh, account_id=<redacted>, server_id=<redacted>, environment_id=<redacted>
INFO codex_app_server_transport::transport::remote_control::websocket: remote control websocket status changed previous_status=Connecting next_status=Connected previous_environment_id=Some("<redacted>") next_environment_id=Some("<redacted>") installation_id=<redacted> server_name=<hostname>.local

The WebSocket reached Connected ~5 seconds after startup. The status query against the same control socket still returned "errored".

3. codex doctor excerpt

      proxy env vars present   HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, NO_PROXY, http_proxy, https_proxy, all_proxy, no_proxy
      connect timeout          15000 ms
      auth mode                chatgpt
      endpoint                 wss://chatgpt.com/backend-api/<redacted>
      DNS                      1 IPv4, 1 IPv6, first IPv6
      handshake result         HTTP 101 Switching Protocols
...
Background Server
  ✓ app-server   running (persistent mode)
      status                   running
      app-server version       0.151.0
      mode                     persistent

What I tried

  • codex app-server daemon start / restart / stop then codex remote-control start (multiple times)
  • codex app-server daemon enable-remote-control
  • Removing stale socket/pid files (app-server-control.sock, app-server.pid) before restart
  • Running codex app-server --remote-control --listen unix:// in the foreground with RUST_LOG=debug — WebSocket connects to Connected, yet codex remote-control --json still reports errored
  • Running with and without proxy env vars (proxy confirmed active in both daemon and foreground processes via ps eww)
  • codex remote-control pair — intermittent: one successful pairing code, otherwise timeout

Notes

  • The mismatch (WebSocket Connected in app-server logs vs. errored in the CLI status query) suggests the status reported by the control socket does not reflect the actual remote-control WebSocket state.
  • codex doctor overall result: 21 ok · 3 notes · 2 warn · 0 fail degraded (the warnings are optional desktop assets CDN reachability, unrelated).
  • Full app-server foreground log (with installation/account IDs redacted) is available on request.

Activity

  1. added
    bug
    CLI
    app-server
    connectivity
    on Aug 29, 2026
  2. kennetsytn commented on Aug 30, 2026

    @kennetsytn
    Author

    ✅ Resolved — Local environment issue

    The remote-control functionality is now working correctly after local environment changes.

    Root Cause Analysis

    The issue was caused by a local proxy configuration conflict, not a codex CLI bug.

    Timeline:

    1. Before fix: codex daemon was started with HTTP_PROXY/HTTPS_PROXY environment variables pointing to a local HTTP proxy (Clash Verge). The daemon inherited these proxy settings from the shell.
    2. Symptom: codex remote-control --json consistently reported "connection is errored", while:
      • codex doctor showed WebSocket HTTP 101 connected
      • Foreground app-server debug logs showed current_status=Connected
      • Pairing code was successfully generated once
    3. After fix: Switched local proxy from HTTP proxy mode to TUN/virtual NIC mode (system-level transparent proxy via utun interface). Removed explicit HTTP_PROXY/HTTPS_PROXY environment variables from the daemon process.

    Why the proxy caused status reporting failures:

    • The daemon's WebSocket connection to wss://chatgpt.com/backend-api/wham/remote/control/server was being routed through the HTTP proxy
    • The WebSocket handshake succeeded (HTTP 101), but the daemon's internal state query mechanism (which reads status from a separate control socket/file) was affected by the proxy interference
    • The status file was either not being written correctly, or the CLI was reading stale/errored state from it
    • TUN mode intercepts traffic at the IP layer transparently, avoiding this conflict

    Environment Details

    • codex-cli 0.151.0 (standalone, macOS arm64)
    • macOS 26.6.2 (Apple Silicon)
    • Local HTTP proxy: Clash Verge (HTTP proxy mode)
    • Fix: Switched to Clash Verge TUN mode (transparent proxy), removed explicit proxy env vars from daemon

    Evidence

    • Doctor: WebSocket connected (HTTP 101 Switching Protocols)
    • Foreground debug logs: previous_status=Connecting to next_status=Connected
    • Daemon process with TUN mode: connected
    • codex remote-control --json: reports connected

    Recommendation

    If other users encounter similar "connection is errored" status while the WebSocket is actually connected, check for HTTP proxy environment variables (HTTP_PROXY, HTTPS_PROXY) that may interfere with the daemon's internal state management. Consider using TUN/virtual NIC transparent proxy mode instead of HTTP proxy mode for the codex daemon.

    Thanks for the great tool! Closing as this was a local environment issue.

  3. lagisela commented on Sep 15, 2026

    @lagisela

    Remote control enrollment never completes on WSL2 (clean install, fresh hostname)

    Codex CLI 0.154.0, standalone install, Ubuntu on WSL2, Windows 11 26200.

    codex remote-control start succeeds and reports "This machine is available for remote control as paul-wsl", but codex remote-control pair always fails with remoteControl/pairing/start failed: remote control pairing is unavailable until enrollment completes, and codex remote-control --json reports "connection is errored".

    Ruled out:

    Auth: fresh codex login --device-auth, successful.
    Host identity: set a unique WSL hostname via /etc/wsl.conf to avoid reusing a previously stuck enrollment record. New name is reported correctly; same failure.
    Competing instances: Windows Codex desktop app and Windows app-server daemon fully stopped.
    Install type: switched from npm @openai/codex to the standalone installer as instructed by the daemon error.
    Waiting: ran start and pair as separate commands with 30s in between.

    No daemon logs are produced at all — ~/.codex/log/ contains only codex-login.log. RUST_LOG=debug codex remote-control start prints nothing beyond the normal output, so there is no error detail to attach.

    On the same machine, native Windows fails earlier with socket directory is not private to the current user (directory ACL verified: owner is the current user, single full-control ACE). WSL2 gets past that point and then fails at enrollment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIapp-serverbugconnectivityremote

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions