ChatGPT-auth websocket connect to chatgpt.com hangs before upgrade; local diagnostics point to IPv6-first address selection
Open 💬 7 comments Opened Mar 3, 2026 by egillax
💡 Likely answer: A maintainer (github-actions[bot], contributor)
responded on this thread — see the highlighted reply below.
Summary
- On Linux with ChatGPT auth, Codex hangs during websocket connect to
wss://chatgpt.com/backend-api/codex/responses. - This does not appear to be a post-upgrade close-frame problem.
- Local instrumentation shows the hang occurs during websocket connect/setup before TLS/websocket upgrade completes.
- In a locally instrumented diagnostic build, preferring/forcing IPv4 makes websocket connect succeed immediately, return
101 Switching Protocols, and the stream complete.
Environment
- Codex CLI version:
0.107.0 - OS: Ubuntu 24.04.4 LTS
- Terminal stack: Alacritty + tmux
- Auth modes compared on same machine:
- ChatGPT auth: failing
- API key auth: working
Stock repro
- Use Codex CLI
0.107.0 - Authenticate with ChatGPT auth
- Start Codex
- Submit a simple prompt such as
hello - Observe that the session hangs and does not produce a response
- Local instrumentation shows this corresponds to websocket connect timing out before upgrade
Diagnostic findings from a local instrumented build
- ChatGPT auth path:
- endpoint:
wss://chatgpt.com/backend-api/codex/responses - auth branch observed in logs:
bearer_plus_chatgpt_account_id - sanitized handshake metadata showed:
- authorization header present
- ChatGPT account id header present
- no cookie header
- DNS resolution was fast
- first resolved candidate was IPv6
- a preflight TCP connect to the first IPv6 candidate timed out
- websocket connect then timed out after 30s
- no TLS/websocket upgrade success was reached
- API key path:
- endpoint:
wss://api.openai.com/v1/responses - auth branch observed in logs:
bearer_only - DNS resolution succeeded
- preflight TCP connect succeeded quickly
- websocket connect succeeded in ~585ms
- stream completed
Strongest diagnostic result
- In a local diagnostic build, I added temporary address-family selection logic only for investigation.
- Under default/system address ordering, the ChatGPT-auth websocket connect timed out.
- When IPv4 was preferred in that diagnostic build:
- TCP connect succeeded on IPv4 in ~13ms
- websocket upgrade succeeded with
101 Switching Protocols - stream completed
- When IPv4-only was used in that diagnostic build:
- same successful outcome
Practical root-cause boundary
- The practical boundary appears to be IPv6/address-selection/fallback behavior to
chatgpt.combefore TLS/websocket upgrade in the current websocket connect path. - This appears distinct from the issue where websocket upgrade succeeds and the server then closes with a policy code.
Suggested fix direction
- Improve websocket dual-stack connect behavior (for example Happy Eyeballs or faster fallback across resolved addresses)
- or expose a supported address-family preference / IPv4 fallback if needed
- current behavior appears to stall too long on the first bad IPv6 candidate
Notes
- API-auth works on the same machine/network, so this does not look like a general websocket/TLS failure.
- The difference appears tied to the
chatgpt.comwebsocket endpoint and its address-selection path. - I can provide the local diagnostic patch details if useful, but the public repro above uses stock Codex behavior.
Concise log excerpts
ChatGPT auth, stock/default behavior:
opening responses websocket connection connect_phase="initial_session_websocket_setup" auth_mode="chatgpt"connecting to websocket: wss://chatgpt.com/backend-api/codex/responseswebsocket connect timed out ... connect_elapsed_ms=30000responses websocket connection failed ... auth_mode="chatgpt"
Local diagnostic build, IPv4-preferred ordering:
resolved_addresses=[IPv6, IPv6, 172.64.155.209:443, 104.18.32.47:443]ordered_addresses=[172.64.155.209:443, 104.18.32.47:443, IPv6, IPv6]candidate tcp success ... address_family="ipv4" tcp_elapsed_ms=13websocket upgrade succeeded ... response_status=101 Switching Protocolsresponses websocket connection established ... auth_mode="chatgpt"
7 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Thanks for the bug report. When Codex cannot connect using websockets, it is designed to fall back to http. Currently, that happens only after five reconnect attempts (you'll see "Reconnecting 1/5" through 5/5 in the message stream), but it should eventually fall back and recover by using http. Does that happen in your case? Or does it hang indefinitely? If it hangs, that's a much worse problem than if it is able to fall back to http and continue after a short delay
In my case it does not appear to recover or fall back to HTTP, at least not within a few minutes.
I also do not see the Reconnecting 1/5 … 5/5 messages in the UI.
Once it gets into that state, Ctrl+C / Ctrl+D do not stop it cleanly for me; the only reliable way I’ve found to exit is killing the tmux window/session.
@egillax Same, does also not fall back to http but I see the 1/5 reconnecting attempts
I'm having the same issue. Its unusable.
Trying to get claude code to debug.
Same issue confirmed on auth token exchange (not just websocket)
Environment
Symptom
codexlogin via ChatGPT auth (option 1) and Device Code (option 2) both fail:Log excerpt:
Root cause confirmation
auth.openai.comresolves to IPv6-only viagetent hosts:IPv6 connectivity is broken on this machine.
curl -4works,curl -6hangs. Codex's reqwest client tries IPv6 first, fails to connect, and does not fall back to IPv4.Also affects
api.github.comandchatgpt.com— all outbound HTTPS from Codex fails:Workaround
Force IPv4 via
/etc/hosts:Login succeeds immediately after this.
Note
This is the same IPv6-first / no-fallback issue as the websocket hang described in this issue, but manifesting earlier in the auth flow. Happy Eyeballs (RFC 6555) in the reqwest client would fix both.
Corroborating on macOS + Tailscale, with a clean version bisection: __0.141.0 works, 0.142.0 is broken.__
__Regression (the actionable bit):__
npm install -g @openai/codex@0.141.0reliably restores it.hickory(-dns) symbol refs than 0.141.0 (157 vs 42), so the connector/resolver path looks like what changed.__Scope (not just the websocket):__
codex login(ChatGPT) givestoken_exchange_failed: error sending request for url (https://auth.openai.com/oauth/token)(same as #26764).responses_http(custom provider withsupports_websockets=false) stalls _identically_ toresponses_websocket, so it is the connection layer, not the transport.__Localization (matches the IPv6-first address-selection theory):__
``
``starting new connection: https://api.openai.com/
(+15.1s) connected to 162.159.140.245:443
digresolves in <150ms, andcurlto the same hosts and IPs is instant, including a manual WebSocket upgrade towss://api.openai.com/v1/responses(returns 401 in 0.6s). macOSgetaddrinfosuppresses AAAA when there is no global IPv6 address, so curl stays on IPv4; Codex's bundled resolver returns AAAA regardless, which fits the IPv6-first selection hypothesis.utuninterfaces and IPv6 routes, a likely dual-stack trigger). Reproduced on two unrelated networks.__Re: the intended HTTP fallback__ - on 0.142.0 it does _not_ recover here; it loops "Reconnecting 1/5 ... 5/5" and stays dead (matching @egillax / @moritzdemmer). Only downgrading to 0.141.0 restored it.