Token exchange fails on IPv6-enabled systems (Linux)

Resolved 💬 3 comments Opened Jan 27, 2026 by ESKRiPO Closed Jan 27, 2026

Bug Report

What version of Codex is running?

codex-cli 0.92.0

What subscription do you have?

ChatGPT Plus

Which model were you using?

N/A (login issue)

What platform is your computer?

Linux 6.18.7-2-cachyos x86_64 (Arch-based)

What issue are you seeing?

codex login and codex login --device-auth both fail with:

Token exchange failed: error sending request for url (https://auth.openai.com/oauth/token)

or

Error logging in with device code: error sending request for url (https://auth.openai.com/api/accounts/deviceauth/usercode)

Root Cause Identified

The issue is IPv6 connectivity. When the system resolves auth.openai.com to an IPv6 address first (e.g., 2a06:98c1:3106::ac40:920f), the Codex CLI fails to connect.

Proof

  1. curl -v https://auth.openai.com works fine (both IPv4 and IPv6)
  2. opencode auth login (different CLI tool using same OAuth endpoint) works fine
  3. After adding IPv4 address to /etc/hosts:

``
172.64.146.15 auth.openai.com
`
codex login --device-auth` works successfully

Expected Behavior

Codex CLI should work on systems with IPv6 enabled, either by:

  • Properly supporting IPv6 connections
  • Falling back to IPv4 when IPv6 fails
  • Using happy eyeballs (RFC 6555) for connection attempts

Workaround

Force IPv4 by adding to /etc/hosts:

172.64.146.15 auth.openai.com

Additional Context

  • The reqwest Rust HTTP client may be the source of the issue
  • This affects Linux users with dual-stack (IPv4+IPv6) networking
  • ISP: Orange Slovakia (standard residential connection)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗