Codex Keeps Reconnecting? Four Fixes
Codex talks to the ChatGPT backend over WebSocket by default. If your network path involves Clash, a corporate proxy, cross-border transit, or Cloudflare challenge pages, that long-lived WebSocket gets killed easily — and you end up staring at Reconnecting... 1/5 over and over. Turn off WebSocket and switch to plain HTTP streaming requests, and the problem mostly disappears.
Why WebSocket Breaks Behind Proxies
The WebSocket protocol starts with an HTTP Upgrade request; only after the server returns 101 does it switch to the long-lived connection. That long-lived connection is exactly where the problem sits — proxy servers, firewalls, and CDN nodes all run timeout policies on idle connections, and Cloudflare’s challenge mechanism can inject an interstitial page mid-path. Any link in that chain kills the connection, and the Codex client starts Reconnecting.