Proxy hostname A succeeds but AAAA SERVFAIL aborts requests before connect()
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.5k
- PR merge metrics
- PR metrics pending
Description
What version of Codex CLI is running?
codex-cli 0.153.4 (bundled with Codex App 26.901.51231)
What subscription do you have?
Enterprise
Which model were you using?
Not applicable. The failure occurs before authentication.
What platform is your computer?
Linux 6.18.33.2-microsoft-standard-WSL2 x86_64 x86_64
What terminal emulator and version are you using (if applicable)?
WSL2 shell. The same failure occurs through Codex Desktop and the bundled CLI.
Codex doctor report
not available in this bundled CLI
What issue are you seeing?
Codex cannot use an HTTP proxy hostname when DNS returns a valid A record but SERVFAIL for the AAAA query.
Both OAuth paths fail with generic transport errors:
Token exchange failed: error sending request for url (https://auth.openai.com/oauth/token)
Error logging in with device code: error sending request for url (https://auth.openai.com/api/accounts/deviceauth/usercode)
curl reaches the same endpoints through the same proxy and validates TLS. A POST without parameters receives the expected HTTP 400 response from OpenAI.
A network syscall trace of codex login --device-auth shows:
- Codex sends A and AAAA queries for the proxy hostname.
- The A query returns one private IPv4 address.
- The AAAA query returns DNS
SERVFAIL. - Codex retries the AAAA query.
- Codex reports
error sending requestwithout callingconnect().
Replacing the proxy hostname in HTTP_PROXY and HTTPS_PROXY with its resolved IPv4 address makes device authorization start immediately. Normal Desktop OAuth token exchange also succeeds after restart.
The proxy hostname and address are omitted because they identify a private corporate network.
What steps can reproduce the bug?
- Configure a DNS name for an HTTP proxy.
- Make its A query return a valid IPv4 address.
- Make its AAAA query return
SERVFAIL, not an emptyNOERRORresponse. - Set
HTTP_PROXYandHTTPS_PROXYtohttp://proxy.example:<port>. - Run:
codex login --device-auth
- Observe that Codex fails before it displays a device code:
Error logging in with device code: error sending request for url (https://auth.openai.com/api/accounts/deviceauth/usercode)
- Confirm that no outbound TCP
connect()occurs:
strace -f -e trace=network codex login --device-auth
- Replace
proxy.examplein the proxy variables with its IPv4 address. - Run the command again. Codex now displays the device URL and one-time code.
What is the expected behavior?
Codex should use the valid A result when the AAAA lookup fails.
If it cannot continue, the error should identify proxy hostname resolution as the cause. It should include the underlying DNS error without exposing proxy credentials.
Additional information
I searched open and closed issues before filing. Related reports include #16079 for generic Linux HTTP proxy failures and #44990 for AAAA-only WSL DNS with unroutable IPv6. This case differs because the destination is not resolved AAAA-only. The proxy A record succeeds, but a SERVFAIL AAAA response causes Codex to discard the usable IPv4 result before any connection attempt.
The issue also exposed that Codex loads proxy settings from $CODEX_HOME/.env. Command-level proxy overrides did not change the trace until that file was updated. This behavior is related to #38885, but the persisted proxy itself was valid; only dual-stack DNS handling failed.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce with codex login --device-auth under WSL2, using HTTP_PROXY/HTTPS_PROXY and strace -f -e trace=network. Trace proxy hostname resolution and request setup, then verify that a valid A result still reaches connect() when AAAA returns SERVFAIL. Done means device auth starts through the hostname, or a proxy-resolution error identifies the DNS failure without credentials.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux, rust
- Domain
- cli, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 65/100