Disconnected Stream

Resolved 💬 8 comments Opened Jan 7, 2026 by aris997 Closed Jan 12, 2026
💡 Likely answer: A maintainer (etraut-openai, contributor) responded on this thread — see the highlighted reply below.

What version of Codex is running?

codex-cli 0.79.0

What subscription do you have?

Using OPENAI_API_KEY (Tier 5)

Which model were you using?

gpt-5.1-codex-max

What platform is your computer?

Linux 6.14.0-37-generic x86_64 x86_64

What issue are you seeing?

■ stream disconnected before completion: error sending request for url (https://api.openai.com/v1/responses)

What steps can reproduce the bug?

Just asking the model to /init the folder, request sent via curl to gpt-4o-mini works but gpt-5.1-codex-xx do not works

Uploaded thread: 019b993d-56fc-7211-8f5e-e60280829d8e

What is the expected behavior?

_No response_

Additional information

_No response_

View original on GitHub ↗

8 Comments

etraut-openai contributor · 6 months ago

Do you have a config.toml file? If so, what options do you have configured in it?

Do you suspect that this was a regression with 0.79? Was this working previously?

aris997 · 6 months ago

No I don't have a config.toml file, actually I was on 0.77.x, I thought it was an update issue, so I closed the chat, updated the npm package. But still the same issue.

aris997 · 6 months ago

It may be related: today _(2026-01-08 14-50-00 UTC)_ I tried to use codex with the same configs (0.79.0, GPT-5.1-codex-max, GNU/Linux Ubuntu 24.04) and I get a different response: 401 Unauthorized. I checked my API KEY is still valid.

API KEY was refreshed yesterday to prevent API KEY related problems.

Uploaded a new feedback with thread ID 019b9e17-df3f-7ca0-bfd7-976ec216ef1e.

etraut-openai contributor · 6 months ago

That seems to indicate that the API key you're using is not valid (e.g. the key is corrupt/incorrect or has been revoked).

Here's what I recommend:

  1. Log out and log back in with your existing API key
  2. Allocate a new API key and try that
aris997 · 6 months ago

Okay, just allocated a new api key.

Tested codex with same environment (same project, folder, OS, codex 0.79.0, model GPT-5.1-codex-max medium), it's back to disconnected stream error. Traceback thread ID is 019ba1df-38ad-7be1-a0ee-7f341cee443b.

Tested the api key with a simple curl query to check working:

$ curl https://api.openai.com/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "gpt-4.1",
    "input": "Tell me a three sentence bedtime story about a unicorn."
  }'
{
  "id": "resp_0315251588f5d51c006960bdd0df18819782a2fa615de1b712",
 ... # omissis #
}
etraut-openai contributor · 6 months ago

Based on the logs, this looks like a basic network connectivity issue. Do you have any network proxy, VPN, or firewall configured on your machine or network? I think you'll need to do some diagnosis of your system to fix this.

aris997 · 6 months ago

I double-checked and the latest issue (updated to 0.80.0) was again 401 Unauthorized.
I found that Codex stores the last working API_KEY in ~/.codex/auth.json. After renaming that file and running Codex again, it prompted me to confirm the current environment API_KEY and then saved it to the same location.
So rotating OPENAI_API_KEY isn’t straightforward if the cached key is still present.
I also haven’t encountered the stream disconnect bug again.
Everything is working now. Thanks for the support.

aris997 · 6 months ago

Indeed just found that connecting via a specific connection (Company intranet via eth) the stream gets disconnected.

Also connecting via VPN, company connection blocks it. 019bb273-5bb9-7fb1-aebc-4dff19ce1b2f.