FeaturesAll featuresServer locationsProtocols & securityNo activity logsUse cases
AppsWindowsmacOSiOSAndroidLinux
Pricing
HelpHelp CenterContact supportBlogChangelog
EnglishEnglish简体中文繁體中文ภาษาไทยTiếng ViệtIndonesiaFrançaisDeutschEspañolРусский
Get ZibVPNSign inMy account
Troubleshooting

OpenAI Codex shows "stream disconnected before completion" when using a VPN. What can I do?

Updated 2026-07-17

If you use OpenAI Codex (the command-line tool) while connected to a VPN, you may see an error like this, interrupting tasks and code reviews:

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

Or it fails after several retries:

Reconnecting... 1/5 (stream disconnected before completion ...)
Reconnecting... 2/5 ...
...
Falling back from WebSockets to HTTPS transport.

This article explains why and gives a complete fix for Windows and macOS.

The short answer

If you use ZibVPN 1.4.0 or later, first lock the protocol to VLESS in the app. Automatic protocol switching will then no longer interrupt Codex's long connections. In our tests, locking VLESS resolves this stream disconnected before completion error.

Update (2026-07): ZibVPN 1.4.0+ supports protocol locking. For Codex, AI agents, remote terminals and other tools that rely on long connections, we recommend VLESS (VLESS+Reality). On an older version, please upgrade from the download page first.

Recommended fix: lock the VLESS protocol in ZibVPN

Codex's WebSocket or HTTP/SSE responses can last several minutes. In "Auto" mode, ZibVPN picks a path among Reality, ShadowTLS, Hysteria2 and AnyTLS based on latency and recent connection quality. You usually won't notice a switch while browsing, but a running Codex stream may have to reconnect.

On ZibVPN 1.4.0 or later:

  1. Open the ZibVPN app and check that the version is 1.4.0 or later.
  2. Click the protocol button in the bottom-right corner of the main screen (it shows the current protocol, e.g. "Auto") to open the protocol menu.
  3. Change "Auto" to VLESS (the actual connection is VLESS+Reality).
  4. Reconnect ZibVPN, then run your Codex task again.

Key point: don't keep the protocol on "Auto" while running Codex; lock it to VLESS. Once locked, the app keeps using the same protocol and won't switch transport paths, so Codex's long connection isn't cut off while it is thinking or writing output.

Why does it disconnect?

Recent versions of OpenAI Codex use WebSocket as the transport by default. A WebSocket is a long-lived connection that has to stay open for a long time, and such connections are easily interrupted when passing through any proxy or VPN, because of:

  • network equipment along the way closing connections that sit idle for too long;
  • WebSocket handshakes timing out behind a proxy;
  • UDP/QUIC-based transports being cut more easily by ISP networks on long connections.

This is a transport compatibility issue in the Codex client, with many identical reports in the community. Fortunately, there is a proven fix.

Fallback: switch Codex to HTTP/SSE

If you can't upgrade ZibVPN yet, or other network factors still affect you after locking VLESS, use this Codex workaround: disable WebSocket and force the more stable HTTP/SSE transport. You only need to edit Codex's config file config.toml.

Already changed the config but still getting frequent disconnects? Check step 2 below carefully. In most cases the key line is in the wrong place and never takes effect (Codex removes it on every start), or the streaming timeout and retry settings need to be raised.

Step 1: find or create the config file

Windows:

C:\Users\YourUsername\.codex\config.toml

macOS:

~/.codex/config.toml

~ is your home folder; the full path is usually /Users/YourUsername/.codex/config.toml. If the .codex folder or the config.toml file doesn't exist, create it yourself (.codex is a hidden folder).

Quick way to open it (optional)

Windows (PowerShell):

notepad "$env:USERPROFILE\.codex\config.toml"

macOS (Terminal):

mkdir -p ~/.codex && open -e ~/.codex/config.toml

Step 2: add the following configuration

Put the following into config.toml. If the file already has content, don't just paste this block at the end. The line model_provider = "openai_http" must be at the very top of the file (before any [...] section); the [model_providers.openai_http] block below it can sit alongside your other sections:

model_provider = "openai_http"   # ← must be the first line, before any [ ] section

[model_providers.openai_http]
name = "OpenAI HTTP only"
base_url = "https://chatgpt.com/backend-api/codex"
wire_api = "responses"
requires_openai_auth = true
supports_websockets = false
# ↓ tolerate long silent reasoning phases and retry more after a drop
stream_idle_timeout_ms = 600000
stream_max_retries = 10
request_max_retries = 8

supports_websockets = false makes Codex skip the WebSocket channel, which drops most easily, and use the more stable HTTP/SSE. The last three lines relax the "no data for too long" disconnect rule and add more retries. During deep reasoning the model often sends nothing for tens of seconds, and the default 5-minute idle timeout is easily mistaken for a drop behind a proxy; raising it noticeably reduces interruptions. (These settings only apply to a custom provider, and openai_http here is exactly that, so they do take effect.)

The most common mistake: the line model_provider = "openai_http" must be at the very top of the file, before any [...] section. Otherwise, under TOML rules it belongs to the [model_providers.openai_http] section and the top-level setting is effectively missing. Codex also removes the misplaced key whenever it rewrites the config on start, which shows up as "I changed it, but it disconnects again after every restart".

❌ Wrong order (placed after a section → removed on every start, no effect):

[model_providers.openai_http]
name = "OpenAI HTTP only"
supports_websockets = false
model_provider = "openai_http"   # ← no effect here, will be removed

✅ Correct order: model_provider = "openai_http" is the first line of the file, and every [...] section comes after it (as in the full example above). Afterwards, run /status in Codex and check that Model provider shows openai_http.

Step 3: save and restart Codex

Save the file, then fully quit and restart Codex (command-line users: exit the current session and run codex again) so the new config takes effect.

Check that it's fixed

  1. Run a Codex task again (for example a code review or a longer conversation).
  2. Watch whether stream disconnected or Reconnecting... x/5 still appears.

In most cases, disabling WebSocket makes it stable again. If it still drops occasionally, try another VPN server.

FAQ

Q: Will this config affect other Codex features?

This is a widely used stability fix in the community. It only changes the transport (from WebSocket to HTTP/SSE) and doesn't affect what Codex can do. If Codex fixes its WebSocket compatibility in the future, you can delete this block to go back to the default.

Q: Is this a VPN problem?

No. This error can happen behind any proxy or VPN. The root cause is how Codex's default transport works with proxies, and changing the Codex config as above fixes it.

Q: I don't use the command line. I use a GUI or another tool.

The idea is the same: avoid unstable WebSocket long connections. If the tool lets you choose a transport, turn off WebSocket and use HTTP/SSE as well.

If the problem persists after these steps, contact us through in-app Feedback or at [email protected] with the full error message, and we will help you look into it.