Linux + HTTP proxy: Codex CLI fails in both API key mode and device-auth mode, while curl works for Responses API
What version of Codex CLI is running?
codex-cli 0.117.0
What subscription do you have?
Organization
Which model were you using?
_No response_
What platform is your computer?
Linux server
What terminal emulator and version are you using (if applicable)?
_No response_
What issue are you seeing?
Codex CLI fails on a Linux server behind an HTTP proxy, even though direct curl works from the same shell session.
I tested all of the following in the same Linux shell:
curlto the OpenAI Responses API works, including streaming:
```bash
curl -N -v https://api.openai.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-5.2",
"input": "say hello",
"stream": true
}'
- Starting
codexin the same shell fails during conversation with:
Stream disconnected before completion: error sending request for url (https://api.openai.com/v1/responses)
- I also tried:
- launching
codexfrom the exact same shell ascurl - explicitly passing proxy-related env vars when starting
codex - upgrading Codex CLI to the latest version
The failure still happens.
- After logging out, I tried ChatGPT device-code login on this headless Linux server:
codex login --device-auth
That also fails, with:
error sending request for url (https://auth.openai.com/api/accounts/deviceauth/usercode)
So in this environment:
- direct
curltohttps://api.openai.com/v1/responsesworks - Codex CLI request path to
https://api.openai.com/v1/responsesfails - Codex CLI device-auth request path to
https://auth.openai.com/api/accounts/deviceauth/usercodealso fails
This makes it look like the CLI’s HTTP/proxy/TLS handling is behaving differently from curl in the same environment.
What steps can reproduce the bug?
- Prepare a Linux server that accesses the internet through an HTTP proxy.
- Export the proxy environment variables in the shell where Codex CLI will be launched, for example:
export https_proxy=http://<proxy-host>:<proxy-port>
export http_proxy=http://<proxy-host>:<proxy-port>
- Verify that direct OpenAI API access works with
curlfrom the same shell:
curl -N -v https://api.openai.com/v1/responses -H "Content-Type: application/json" -H "Authorization: Bearer $OPENAI_API_KEY" -d '{"model":"gpt-5.2","input":"say hello","stream":true}'
- Launch Codex CLI from that same shell:
codex
- Send any prompt in Codex CLI.
- Observe that the request fails with:
Stream disconnected before completion: error sending request for url (https://api.openai.com/v1/responses)
- Log out and try device-code authentication:
codex logout
codex login --device-auth
- Observe that device auth also fails with:
error sending request for url (https://auth.openai.com/api/accounts/deviceauth/usercode)
What is the expected behavior?
_No response_
Additional information
_No response_
9 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
This sounds specific to your proxy configuration. You'll need to investigate further and diagnose the problem.
Thanks. I agree the proxy is part of the environment, but I don't think this has been narrowed down to "just a proxy misconfiguration" yet.
Here is why I opened the issue:
curltohttps://api.openai.com/v1/responsesworks from the same Linux servercodexfails from the same shell session, with the same proxy env varscodex logout,codex login --device-authalso fails onhttps://auth.openai.com/api/accounts/deviceauth/usercodeI have a useful update.
As a workaround, I asked another AI tool to generate a small local proxy service. It runs as an HTTP server on
127.0.0.1:9999, accepts Codex requests locally, and then forwards them to OpenAI through my existing proxy setup.After that, I updated
~/.codex/config.tomlto use the local service:With this configuration, Codex works.
To me, this strongly suggests the issue is not simply “my proxy is broken”. The same environment fails when Codex talks to OpenAI directly, but succeeds when Codex talks to a local HTTP service that forwards the request through the proxy.
That points to some difference in how Codex handles direct outbound proxy/TLS/networking compared with other clients.
This workaround took hours to figure out, so I do think this issue deserves investigation, even if the root cause is an interaction with certain proxy environments.
I also encountered the same problem. I looked into many issues, but it seems that the developers never regarded this as a problem. It's quite strange. Have they ever used Codex in the proxy scenario themselves?
Encounter the same problem
PSA: The issue is with TLS, you need to have your proxy/gateway support TLS1.2 until codex (Mac ARM) is fixed to support TLS1.3
There is clearly some issue with codex app about this,- in my case update to latest codex caused the same error, while minutes before everything was fine. I was not running traffic through any proxy and the issue also persists with reboot, while everything else works fine and as usual.
Was able to get codex working again for me, in my case the DNS resolution in WSL instance was broken, you can confirm it with running this in your WSL machine:
If this says name or service not known and the following ping returns normal answer:
Then your issue is most likely in
Quickfix: set google DNS as nameserver. This should make codex work again and from that moment on you can tell him to find out why it happened in the first place. resolv.conf should look something like this then:
and curl to auth.openai.com should now work again.
== UPDATE ==
found the source of the problem, it seems to be an issue with stale HSN Firewall rules. I used the following commands, found under https://learn.microsoft.com/en-us/windows/wsl/troubleshooting under "Troubleshooting DNS in WSL" under point 4.:
(note this will remove firewall rules for port 53/udp, usually not a problem unless you have explicit custom setup there).
Then set DNS to local resolver and it my old setup before the quickfix (setting google dns), was working again as usual.