Skip to content

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

Closed

Description

@Supercox72

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

Image

Activity

  1. added
    bugSomething isn't working
    CLIIssues related to the Codex CLI
    on Mar 6, 2026
  2. rockyicer commented on Mar 6, 2026

    @rockyicer

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

  3. puremachinery commented on Mar 7, 2026

    @puremachinery

    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.

  4. Supercox72 commented on Mar 7, 2026

    @Supercox72
    Author

    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!

    Image
  5. Supercox72 commented on Mar 7, 2026

    @Supercox72
    Author

    I've also noticed the following oddities:

    Unable to upload files:
    Image

    I downloaded & installed the Codex App from the Microsoft Store. I am having connectivity issues with it as well:
    Image

    Sign-in could not be completed with Codex:
    Image

  6. etraut-openai commented on Mar 7, 2026

    @etraut-openai
    Contributor

    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.

  7. mikehalma commented on Mar 9, 2026

    @mikehalma

    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.

  8. Supercox72 commented on Mar 9, 2026

    @Supercox72
    Author

    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
  9. Supercox72 commented on Mar 9, 2026

    @Supercox72
    Author

    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.

  10. mikehalma commented on Mar 10, 2026

    @mikehalma

    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? 😢

  11. knollmeyersam-dot commented on Mar 13, 2026

    @knollmeyersam-dot

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

  12. jb-san commented on Mar 26, 2026

    @jb-san

    Seeing this on every session

  13. mikehalma commented on Mar 26, 2026

    @mikehalma

    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.

  14. bnllb commented on Apr 19, 2026

    @bnllb

    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.

  15. etraut-openai commented on Apr 19, 2026

    @etraut-openai
    Contributor

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

  16. Groverlee commented on Apr 20, 2026

    @Groverlee

    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 logout → rm ~/.codex/auth.json → codex 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.

  17. snoopuppy582 commented on May 24, 2026

    @snoopuppy582

    same to me

  18. chengligen commented on May 27, 2026

    @chengligen

    same problem

  19. c0dezli commented on Jun 3, 2026

    @c0dezli

    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

  20. cshhanec2 commented on Jun 7, 2026

    @cshhanec2

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

    1. Скачать последнюю версию Happ (pre-release) с этой репы: https://github.com/Happ-proxy/happ-desktop/releases (2.17.1)
    2. Настроить как на показано на скринах:
    Image Image Image
    1. Пользуйтесь!
  21. Haxel0rd commented on Jul 16, 2026

    @Haxel0rd

    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.

  22. 0xYubo commented on Jul 20, 2026

    @0xYubo

    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)
    2. During use, requests fail with:
      stream disconnected before completion: error sending request for url
      (https://chatgpt.com/backend-api/codex/responses)
    3. ...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

  23. SkiesOfTheKuth commented on Sep 9, 2026

    @SkiesOfTheKuth

    Still having this issue.

  24. smbell1979 commented on Sep 10, 2026

    @smbell1979

    This is making Astra 100% unusable for me.

    I have yet to have any successful chats. Just constant stream disconnected errors.

  25. LiuJunyuan020919 commented on Sep 16, 2026

    @LiuJunyuan020919

    I have solved this problem haha.(I use codex on VPN).check & change your own VPN node;add "export http_proxy=http://127.0.0.1:7897
    export https_proxy=https://127.0.0.1:7897" to ~/.bashrc ,and then "source ~/.bashrc" in your terminal .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIIssues related to the Codex CLIbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions