Codex Error: stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses)

Resolved 💬 22 comments Opened Mar 6, 2026 by Supercox72 Closed Mar 9, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses)

I started getting this at my office on Wednesday evening March 4, 2026 and regularly receiving them at my home since then Wednesday through Friday March 6, 2026.

<img width="640" height="1080" alt="Image" src="https://github.com/user-attachments/assets/860f9598-8190-4404-b018-9b8f12234367" />

View original on GitHub ↗

22 Comments

github-actions[bot] contributor · 4 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #13245
  • #12766
  • #12734
  • #12207
  • #12206

Powered by Codex Action

rockyicer · 4 months ago

same happen to me.
log out and log in again solve the issue for me.

puremachinery · 4 months ago
same happen to me. log out and log in again solve the issue for me.

I tried logging out and back in and it did not resolve the issue.

Supercox72 · 4 months ago

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

I took the bait... desperate to get this working again and then I can't get logged back in!
Five separate times (& counting) without luck!

<img width="1499" height="175" alt="Image" src="https://github.com/user-attachments/assets/a80cf391-f311-4076-9f55-0b938e6713c2" />

Supercox72 · 4 months ago

I've also noticed the following oddities:

Unable to upload files:
<img width="1013" height="664" alt="Image" src="https://github.com/user-attachments/assets/161bacd5-3cbe-4b98-ba6e-87e4f79fd8a6" />

I downloaded & installed the Codex App from the Microsoft Store. I am having connectivity issues with it as well:
<img width="960" height="1080" alt="Image" src="https://github.com/user-attachments/assets/69ba38f8-2f0f-4ee4-9ebf-0f1cd930d097" />

Sign-in could not be completed with Codex:
<img width="705" height="392" alt="Image" src="https://github.com/user-attachments/assets/6047789c-e8ed-4a80-be26-e3de6b2c1d94" />

etraut-openai contributor · 4 months ago

This looks like a basic network connectivity issue. Are you using a VPN, proxy, firewall, or any other software that could affect networking? We find that's a common cause of connectivity issues like this.

mikehalma · 4 months ago

I have the same - codex randomly stopped working today with error 'stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses)'. Initially from Intellij, but then installed the codex CLI and the same happens. Not on a VPN. Have general connectivity for everything else so not buying the "basic network connectivity" excuse. Feels more like a bug your end tbh.

Supercox72 · 4 months ago

I was able to get it working with the help of ChatGPT...
Final Root Causes

  • Broken IPv6 routing
  • Windows Defender Controlled Folder Access blocking Codex
  • Occasional OAuth redirect issue when CLI and Desktop share browser sessions
Supercox72 · 4 months ago
I have the same - codex randomly stopped working today with error 'stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses)'. Initially from Intellij, but then installed the codex CLI and the same happens. Not on a VPN. Have general connectivity for everything else so not buying the "basic network connectivity" excuse. Feels more like a bug your end tbh.

I initially thought the same things, but then I dug into it with ChatGPT and was able to resolve my issues with my PC & Verizon internet router that I have in my residence.

mikehalma · 4 months ago

It was a good idea getting chatgpt to help troubleshoot the problem. Unfortunately it's exhausted all options and is convinced this is a bug and I should report it. Where it will be ignored because it can't be reproduced. It's hard work isn't it? 😢

knollmeyersam-dot · 4 months ago

happens all day long every day, multple devices, multiple locations. connection is 1gbs, so clearly an openai gateway issue

jb-san · 3 months ago

Seeing this on every session

mikehalma · 3 months ago
It was a good idea getting chatgpt to help troubleshoot the problem. Unfortunately it's exhausted all options and is convinced this is a bug and I should report it. Where it will be ignored because it can't be reproduced. It's hard work isn't it? 😢

Oh I should have updated. Eventually ChtGPT blamed some drivers in ubuntu 20. A fresh install of Ubuntu 24 fixed the problem and not had any bother since.

bnllb · 3 months ago
This looks like a basic network connectivity issue. Are you using a VPN, proxy, firewall, or any other software that could affect networking? We find that's a common cause of connectivity issues like this.

i have meet this issue multiple times this days: submit an spec before sleep, but see this error on the morning. can you please add an auto retry policy.

etraut-openai contributor · 3 months ago

@bnllb, we do have an auto retry policy. It retries up to five times with back-off. If it fails five times in a row, we consider it unrecoverable and stop.

Groverlee · 3 months ago

Environment

  • codex-cli version: 0.121.0 (latest as of 2026-04-19)
  • Install path: /home/groverlee/.claude/plugins/cache/openai-codex/codex/1.0.3/
  • Node.js: v18.19.1
  • OS: Linux (Ubuntu, kernel 6.17.0-20-generic)
  • Auth method: ChatGPT OAuth (active, verified)
  • Model: gpt-5.4 (with model_reasoning_effort = "xhigh" in ~/.codex/config.toml, but also reproduces on medium)
  • Workflow: Using codex-companion.mjs review --background from Claude Code plugin wrapper

What happens

/codex:review and /codex:rescue consistently fail on one specific repository with the following pattern:

[codex] Starting Codex review thread.
[codex] Thread ready (019da88e-7dd5-7203-9a24-ec1bc6acb711).
[codex] Reviewer started: current changes
[codex] Codex error: Reconnecting... 1/5
[codex] Codex error: Reconnecting... 2/5
[codex] Codex error: Reconnecting... 3/5
[codex] Codex error: Reconnecting... 4/5
[codex] Codex error: Reconnecting... 5/5
[codex] Codex error: Reconnecting... 1/5  (second round)
[codex] Codex error: Reconnecting... 2/5
...
[codex] Codex error: stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses)
[codex] Reviewer finished.
[codex] Assistant message captured: Review was interrupted. Please re-run /review and wait for it to complete.
[codex] Turn failed.

After Reviewer started: current changes, the stream stays at zero bytes of payload for 60-90 seconds, then enters the Reconnecting loop and eventually dies. No reasoning tokens, no output text — nothing is emitted.

Scope of reproduction

On this one repository, across a single session (2026-04-19 night → 2026-04-20 morning):

| Attempts | Result |
| -------- | ----------------------------------- |
| 20 | 0 successful, 20 same-mode failures |

The same account (groverpumc@gmail.com, ChatGPT OAuth) previously completed a full /codex:review cycle on a different, smaller repository (test_cc_code) earlier in the same evening, returning a 9-issue review→fix→verify loop in ~8 minutes. So the auth, binary, and network path work in general — the failure is bound to this particular repo or the repo's diff pattern.

What I tried (eliminated as causes)

  • Plugin reinstall (npm install -g @openai/codex): no change.
  • codex logoutrm ~/.codex/auth.jsoncodex login: no change.
  • model_reasoning_effort: tested xhigh and medium, both fail identically.
  • Review gate toggle (enable / disable): no effect on manual review failures.
  • OPENAI_API_KEY: not set (no conflict with ChatGPT OAuth).
  • MCP servers: ~/.codex/config.toml has no [mcp_servers.*] entries.
  • Diff size: fails on both a 48-line single-file diff and an 800-line multi-file diff.
  • Working-tree scope vs. branch scope: both fail the same way.
  • experimental_use_rmcp_client: not set (default).

Minimum reproduction

  1. git init a repository.
  2. Add one small file (e.g., a 48-line shell script).
  3. git add <file> so the working tree has a staged diff.
  4. Run /codex:review --background (or node codex-companion.mjs review --background).
  5. Observe: thread is ready, reviewer starts, then zero-byte silence for ~60s → Reconnecting 1/5 → … → stream disconnected.

Request

If this is a known issue tracked under an existing ticket, please point me there and I'll add my logs as an additional datapoint. Otherwise, any diagnostic information you need (full session log, Codex session IDs, etc.) I can provide.

Related open issues that look similar: #13811, #13245, #8465, #14583.

snoopuppy582 · 1 month ago

same to me

chengligen · 1 month ago

same problem

c0dezli · 1 month ago

same problem and with the lastest update the
`
Add the following configuration in ~/.codex/config.toml:
model_provider = "openai_http"

[model_providers.openai_http]
name = "OpenAI HTTP only"
wire_api = "responses"
requires_openai_auth = true
supports_websockets = false
base_url = "https://chatgpt.com/backend-api/codex"`

approach stoped working too

cshhanec2 · 1 month ago

Если вы с россии, то вот гайд как исправить это и пользоваться Codex в режиме proxy (tun)

  1. Скачать последнюю версию Happ (pre-release) с этой репы: https://github.com/Happ-proxy/happ-desktop/releases (2.17.1)
  2. Настроить как на показано на скринах:

<img width="497" height="496" alt="Image" src="https://github.com/user-attachments/assets/4b87e8a9-5cab-4d49-a78c-8f5656d44c66" />
<img width="827" height="525" alt="Image" src="https://github.com/user-attachments/assets/677aad87-fe76-4854-ad55-183c649e26ce" />
<img width="818" height="465" alt="Image" src="https://github.com/user-attachments/assets/9086db68-9e68-4317-8af9-73dbd939e483" />

  1. Пользуйтесь!
Haxel0rd · 4 days ago

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:

curl -v https://auth.openai.com

If this says name or service not known and the following ping returns normal answer:

ping 8.8.4.4

Then your issue is most likely in

/etc/resolv.conf

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:

user@wsl:\~$ cat /etc/resolv.conf nameserver 8.8.8.8 nameserver 8.8.4.4 options timeout:2 attempts:2 user@wsl:\~$

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.:

PS C:\Windows\system32> wsl --shutdown PS C:\Windows\system32> Get-NetFirewallRule -Name "HNS*" | Get-NetFirewallPortFilter | where Protocol -eq UDP | where LocalPort -eq 53 | Remove-NetFirewallRule PS C:\Windows\system32> hnsdiag.exe delete all PS C:\Windows\system32> Restart-Service hns

(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.

0xYubo · 1 day ago

Fix: token_exchange_failed on login and stream disconnected before completion during use

Environment: Codex CLI 0.136.0 on macOS, using a local HTTP proxy (Clash-style).

Symptoms

Inconsistent proxy environment variables. My shell had the lowercase and uppercase proxy variables pointing to different ports:

https_proxy = http://127.0.0.1:7897 # correct (my real proxy port)
HTTPS_PROXY = http://127.0.0.1:7899 # WRONG port — nothing listening there

curl uses the lowercase https_proxy, so a manual curl https://auth.openai.com/oauth/token worked fine (returned an expected 405, proving the network path was OK). But Codex reads the uppercase HTTPS_PROXY, so it sent the OAuth token exchange (and later the streaming responses requests) to port 7899, where no proxy was listening — hence error sending request for url.

Fix

Make all proxy variables consistent and point to the actual proxy port:

export http_proxy="http://127.0.0.1:7897"
export https_proxy="http://127.0.0.1:7897"
export HTTP_PROXY="http://127.0.0.1:7897"
export HTTPS_PROXY="http://127.0.0.1:7897"
export ALL_PROXY="socks5://127.0.0.1:7897"

Update these in your shell profile (~/.zshrc / ~/.bashrc), then open a new terminal (or source the file) and launch Codex from that session.

Tip: Grep your profile to catch stale/duplicate proxy lines that override each other:
grep -rn -i "proxy" ~/.zshrc ~/.zprofile ~/.bashrc ~/.bash_profile

Note on the streaming error

The stream disconnected before completion error hits the SSE endpoint backend-api/codex/responses, which holds a long-lived streaming connection. If it persists even after the ports are consistent, the proxy itself is likely dropping long connections. Things that helped:

  • Switch the proxy client to TUN mode instead of an HTTP proxy — much more reliable for SSE/HTTP2 streams.
  • Try a different/more stable proxy node.
  • Make sure chatgpt.com / openai.com are routed through the proxy (not DIRECT) in your rules.

---
Want me to shorten it into a comment-sized version, or format it as a full issue with a title?

  1. Login fails with:

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

  1. During use, requests fail with:

stream disconnected before completion: error sending request for url
(https://chatgpt.com/backend-api/codex/responses)

  1. ...and it gives up after retrying ~5 times.

Root cause

Inconsistent proxy environment variables. My shell had the lowercase and uppercase proxy variables pointing to different ports:

https_proxy = http://127.0.0.1:7897 # correct (my real proxy port)
HTTPS_PROXY = http://127.0.0.1:7899 # WRONG port — nothing listening there

curl uses the lowercase https_proxy, so a manual curl https://auth.openai.com/oauth/token worked fine (returned an expected 405, proving the network path was OK). But Codex reads the uppercase HTTPS_PROXY, so it sent the OAuth token exchange (and later the streaming responses requests) to port 7899, where no proxy was listening — hence error sending request for url.

Fix

Make all proxy variables consistent and point to the actual proxy port:

export http_proxy="http://127.0.0.1:7897"
export https_proxy="http://127.0.0.1:7897"
export HTTP_PROXY="http://127.0.0.1:7897"
export HTTPS_PROXY="http://127.0.0.1:7897"
export ALL_PROXY="socks5://127.0.0.1:7897"

Update these in your shell profile (~/.zshrc / ~/.bashrc), then open a new terminal (or source the file) and launch Codex from that session.

Tip: Grep your profile to catch stale/duplicate proxy lines that override each other:
grep -rn -i "proxy" ~/.zshrc ~/.zprofile ~/.bashrc ~/.bash_profile