Skip to content

Codex "Reconnecting…" and Stream Disconnected via Proxy

Find out in a few minutes whether Codex is failing on the proxy, on the exit IP or on your local setup.

The 3 most common causes

The proxy Codex is told to use is not there. A leftover HTTPS_PROXY, HTTP_PROXY or ALL_PROXY (in your shell, or in the .env file in Codex's home folder) can point at a local client such as 127.0.0.1:7890 that you have closed. Codex then reports only the OpenAI address it could not reach, so it looks like an OpenAI or network failure.

The proxy URL is not one Codex can use. Codex reads HTTPS_PROXY first and then ALL_PROXY, and it does not support socks5:// addresses. An HTTP proxy URL such as http://LOGIN:PASSWORD@HOST:PORT works; a SOCKS5 line does not.

The connection is opened but cut while the answer streams. Codex receives replies as a long-lived stream. A proxy, firewall or antivirus that closes idle or long connections ends the stream in the middle of a reply, which Codex reports as a disconnect.

What you see and where to look first

What you see and where to look first
ItemLikely causeFirst check
"failed to connect" … "Connection refused", then a fallback from WebSockets to HTTPSA proxy address with nothing listening behind itStep 2 and 3 below
"stream disconnected before completion: error sending request for url"No route to the OpenAI address: wrong proxy URL, blocked port, or a network that needs a proxyStep 1 and 4
"Reconnecting…" that never recovers, while a browser worksBrowser uses the system proxy, the terminal does not (or the reverse)Step 1 and the setup guide
Works for a short reply, drops on long onesAn idle or total-time limit on the proxy or a firewallStep 6

Message texts are quoted from an openai/codex GitHub issue read on 19 November 2026; the "first check" column is our own order of checking, not an official list.

Seven checks in order

  1. Step 1: See which proxy variables Codex gets

    Run the first command below in the same terminal you start codex from. HTTPS_PROXY wins, ALL_PROXY is the fallback, NO_PROXY lists hosts that skip the proxy. A proxy set in the shell of a desktop app or an editor extension is not visible to a terminal, and the reverse.

    Expected result You see the exact proxy address Codex will try, or nothing at all.

  2. Step 2: Look in Codex's own .env

    Codex reads a .env file in its home folder (~/.codex by default, or the folder CODEX_HOME names). A user reported in openai/codex issue 38885 that an old HTTPS_PROXY line there, pointing at a closed local port, produced exactly the symptoms in this page. Print the proxy lines with the second command, which hides passwords, and delete or fix the stale ones after taking a backup.

    Expected result No proxy line, or only lines you recognise.

  3. Step 3: Make sure the local proxy is really running

    If a variable points at 127.0.0.1 or localhost, check that something listens on that port (third command; on Windows use netstat -ano). If not, start your proxy client, or remove the variable.

    Expected result The port shows a listening process.

  4. Step 4: Test the proxy without Codex

    Run the fourth command with your real details. An HTTP status of 200 plus JSON means the proxy and the exit work. A timeout, 407 or a reset means the problem is in the proxy line, the credentials or the network, so fix that first with the proxy checks in the guides below.

    Expected result HTTP 200 from ipinfo.io through the proxy.

  5. Step 5: Use an HTTP proxy URL, not SOCKS5

    Set HTTPS_PROXY to http://LOGIN:PASSWORD@HOST:PORT. If your tool only gives you a socks5:// line, use the HTTP entry of the same account instead. Special characters in the password must be URL-encoded.

    Expected result codex starts and the first prompt streams.

  6. Step 6: Rule out a time limit on the path

    Try a short prompt and a long one, then repeat on a clean network such as a phone hotspot with no proxy or VPN. If only the proxy path drops long replies, the limit is on that path (proxy, firewall, antivirus, corporate TLS inspection). For a company TLS proxy, point CODEX_CA_CERTIFICATE at the PEM bundle before signing in.

    Expected result The same prompt completes on the clean network.

  7. Step 7: Check the exit IP and the account side

    If the proxy works but the sign-in or requests are still refused, look at the exit country against OpenAI's supported list and at the IP's reputation. A shared or flagged exit can fail where a clean fixed one works.

    Expected result The exit country is one OpenAI supports and the IP is not flagged.

The four commands for steps 1 to 4

# 1) which proxy variables does Codex see in this shell?
env | grep -i _proxy

# 2) proxy lines saved in Codex's own .env (hide passwords before pasting anywhere)
grep -iE '_proxy' "${CODEX_HOME:-$HOME/.codex}/.env" | sed -E 's#//[^@/]*@#//***@#'

# 3) is a local proxy (for example 127.0.0.1:7890) really listening? (macOS/Linux)
lsof -nP -iTCP:7890 -sTCP:LISTEN

# 4) does the proxy itself work? HTTP proxy URL, same form as HTTPS_PROXY
curl -sS -o /dev/null -w '%{http_code}\n' -x http://LOGIN:PASSWORD@HOST:PORT https://ipinfo.io/json

Example only: replace LOGIN, PASSWORD, HOST and PORT with your own values; 7890 is just an example port.

When a symptom does not match

Reconnecting right after you start codex, every time

Check Env proxy variables and the .env file in Codex home (steps 1 and 2).

Fix Remove the stale line or start the proxy it points at, then restart codex.

Stop when Stop at step 2 if the .env file is empty and no variable is set: the proxy is not the cause.

Works in curl, fails in Codex

Check Codex uses HTTPS_PROXY or ALL_PROXY from its own environment, not your browser settings; a socks5:// value is rejected.

Fix Export an http:// proxy URL in the terminal that starts codex.

Stop when If the same HTTP URL fails in both curl and Codex, test another exit rather than editing Codex.

Drops only on long answers

Check A timeout on the proxy path (step 6).

Fix Compare with a clean network; raise the idle timeout on a proxy you run yourself.

Stop when Do not keep restarting Codex: the same path will cut the stream again.

A stable HTTP exit for Codex with Proxy302

If your own proxy keeps dropping, a fixed static ISP address with an HTTP line (port 2222) gives Codex one stable exit: US$0.50 for 1 day or US$7.99 for 30 days per IP, and each IP uses the protocol you pick at purchase, so pick HTTP for Codex. There is no free trial, and the smallest purchase is one IP for one day.

Open My assets after the order and copy HOST, PORT, USERNAME and PASSWORD into HTTPS_PROXY. Check the exit with ipinfo.io before you start Codex, and make sure the country is on OpenAI's supported list. No proxy can promise that an account is never limited.

Common questions

Why does Codex say "stream disconnected before completion"?

It means the streamed reply ended before Codex received the completion message. Behind a proxy the usual reasons are an unreachable proxy address, a proxy URL Codex cannot use, or a path that cuts long connections. Work through steps 1 to 6.

Does Codex CLI work with a SOCKS5 proxy?

No. Codex uses HTTPS_PROXY and then ALL_PROXY, and it rejects socks5:// schemes. Use an HTTP proxy URL; the setup guide shows the exact lines.

Codex says Reconnecting but my browser works. Why?

Browsers use the system proxy or an extension; a terminal program only sees the environment variables of that terminal and Codex's own .env file. Compare them as in steps 1 and 2.

Where is the Codex .env file?

In Codex's home folder: ~/.codex/.env by default, or the folder named by CODEX_HOME. Check it for old proxy lines, and do not paste it whole into a public issue because proxy URLs can hold passwords.

Is it the proxy or an OpenAI outage?

Run the same prompt on a clean network with no proxy or VPN. If it works there and fails on the proxy path, the proxy path is the cause. If it fails on both, check OpenAI's status and your sign-in.

Further reading

Setup guides Proxy302 publishes on GitHub on the same topic:

Reference links

4
  1. openai/codex issue 38885: stale proxy in CODEX_HOME .env

    Third-party source · Confirmed on:

    Read on 19 November 2026: a user traced "failed to connect to websocket … Connection refused", the fallback from WebSockets to HTTPS and "stream disconnected before completion" to proxy lines in the .env file in the Codex home folder that pointed at a local port with nothing listening; removing that file from the home folder fixed it.

  2. openai/codex source: outbound_proxy.rs

    Official documentation · Confirmed on:

    Read on 19 November 2026: Codex takes HTTPS_PROXY, then ALL_PROXY, for HTTPS and secure WebSocket connections, honours NO_PROXY, and has an unsupported-proxy-scheme error; the checked source builds the HTTP client without SOCKS support.

  3. Codex authentication docs

    Official documentation · Confirmed on:

    Read on 19 November 2026: CODEX_CA_CERTIFICATE can name a PEM bundle for a corporate TLS proxy, used when signing in.

  4. Proxy302 product facts and price list

    Product observation · Confirmed on:

    Product facts file of the site, checked 10 to 19 November 2026: static ISP per IP US$0.50 for 1 day and US$7.99 for 30 days, HTTP on port 2222, protocol chosen at purchase, no free trial.

Ready to try it?

Create an account, top up once, then pick rotating residential, static ISP or datacenter IPs and have one running in your browser within minutes.