Client or integration
Codex CLI
Area
CLI
Summary
After running ocx service install in a Windows 10 + WSL environment, Codex requests continuously return 502 Bad Gateway and the Codex client repeatedly reconnects.
Environment
This issue occurs on Windows 10 when OpenCodex and Codex run inside WSL.
- Host operating system: Windows 10
- Runtime environment: Linux inside WSL
- Repository: https://github.com/lidge-jun/opencodex
- OpenCodex version:
2.26.0
- Service manager: systemd user service inside WSL
- Local proxy endpoint:
http://<LOOPBACK_HOST>:<OPENCODEX_PORT>/v1
- Provider: OpenAI / ChatGPT Codex backend
WSL Proxy Configuration
The Windows host runs a local proxy on <PROXY_PORT>. The proxy environment variables are configured inside WSL using the Windows host address obtained from the WSL default route.
The following configuration is used in WSL:
WIN_HOST=$(ip route | awk '/default/ {print $3; exit}')
PROXY_PORT="<PROXY_PORT>"
LOOPBACK_V4="<LOOPBACK_IP_V4>"
LOOPBACK_V6="<LOOPBACK_IP_V6>"
WILDCARD_IP="<WILDCARD_IP>"
export HTTP_PROXY="http://${WIN_HOST}:${PROXY_PORT}"
export HTTPS_PROXY="http://${WIN_HOST}:${PROXY_PORT}"
export ALL_PROXY="socks5h://${WIN_HOST}:${PROXY_PORT}"
export NO_PROXY="localhost,${LOOPBACK_V4},${LOOPBACK_V6},${WILDCARD_IP},${WIN_HOST}"
export http_proxy="$HTTP_PROXY"
export https_proxy="$HTTPS_PROXY"
export all_proxy="$ALL_PROXY"
export no_proxy="$NO_PROXY"
The configuration is persisted in the WSL shell startup file:
# ~/.bashrc
WIN_HOST=$(ip route | awk '/default/ {print $3; exit}')
PROXY_PORT="<PROXY_PORT>"
LOOPBACK_V4="<LOOPBACK_IP_V4>"
LOOPBACK_V6="<LOOPBACK_IP_V6>"
WILDCARD_IP="<WILDCARD_IP>"
export HTTP_PROXY="http://${WIN_HOST}:${PROXY_PORT}"
export HTTPS_PROXY="http://${WIN_HOST}:${PROXY_PORT}"
export ALL_PROXY="socks5h://${WIN_HOST}:${PROXY_PORT}"
export NO_PROXY="localhost,${LOOPBACK_V4},${LOOPBACK_V6},${WILDCARD_IP},${WIN_HOST}"
export http_proxy="$HTTP_PROXY"
export https_proxy="$HTTPS_PROXY"
export all_proxy="$ALL_PROXY"
export no_proxy="$NO_PROXY"
Reproduction Steps
- Start Windows 10 and open the WSL distribution.
- Configure the proxy environment variables inside WSL.
- Install and configure OpenCodex inside WSL.
- Run:
- Start a conversation with GPT through Codex.
Actual Result
The Codex interface continuously displays:
Reconnecting... 2/5 (19s • esc to interrupt)
The request then fails with:
Unexpected status 502 Bad Gateway:
Provider unreachable:
The socket connection was closed unexpectedly.
For more information, pass `verbose: true` in the second argument to fetch(),
url: http://<LOOPBACK_HOST>:<OPENCODEX_PORT>/v1/responses
The OpenCodex log contains:
[upstream-retry] connection reset (<UPSTREAM_HOST>) — retrying
The request record contains:
{
"provider": "openai",
"status": 502,
"recoveryKinds": ["connection-reset"]
}
Comparison
In the same Windows 10 + WSL environment, run:
Then install the Codex shim:
After installing the Codex shim, conversations with GPT through Codex complete successfully. The following errors do not occur:
```text
502 Bad Gateway
connection reset (<UPSTREAM_HOST>)
The socket connection was closed unexpectedly
Expected Result
After running ocx service install in the Windows 10 + WSL environment, conversations with GPT through Codex should complete successfully, with behavior consistent with ocx codex-shim install.
环境
该问题发生在 Windows 10 系统中,OpenCodex 和 Codex 运行在 WSL 环境内。
http://<LOOPBACK_HOST>:<OPENCODEX_PORT>/v1
- Provider:OpenAI / ChatGPT Codex backend
WSL 中的代理配置
Windows 主机上的本地代理监听 <PROXY_PORT> 端口。WSL 中通过默认路由获取 Windows 主机地址,并设置代理环境变量。
WSL 中使用以下配置:
WIN_HOST=$(ip route | awk '/default/ {print $3; exit}')
PROXY_PORT="<PROXY_PORT>"
LOOPBACK_V4="<LOOPBACK_IP_V4>"
LOOPBACK_V6="<LOOPBACK_IP_V6>"
WILDCARD_IP="<WILDCARD_IP>"
export HTTP_PROXY="http://${WIN_HOST}:${PROXY_PORT}"
export HTTPS_PROXY="http://${WIN_HOST}:${PROXY_PORT}"
export ALL_PROXY="socks5h://${WIN_HOST}:${PROXY_PORT}"
export NO_PROXY="localhost,${LOOPBACK_V4},${LOOPBACK_V6},${WILDCARD_IP},${WIN_HOST}"
export http_proxy="$HTTP_PROXY"
export https_proxy="$HTTPS_PROXY"
export all_proxy="$ALL_PROXY"
export no_proxy="$NO_PROXY"
配置持久化在 WSL 的 shell 启动文件中:
# ~/.bashrc
WIN_HOST=$(ip route | awk '/default/ {print $3; exit}')
PROXY_PORT="<PROXY_PORT>"
LOOPBACK_V4="<LOOPBACK_IP_V4>"
LOOPBACK_V6="<LOOPBACK_IP_V6>"
WILDCARD_IP="<WILDCARD_IP>"
export HTTP_PROXY="http://${WIN_HOST}:${PROXY_PORT}"
export HTTPS_PROXY="http://${WIN_HOST}:${PROXY_PORT}"
export ALL_PROXY="socks5h://${WIN_HOST}:${PROXY_PORT}"
export NO_PROXY="localhost,${LOOPBACK_V4},${LOOPBACK_V6},${WILDCARD_IP},${WIN_HOST}"
export http_proxy="$HTTP_PROXY"
export https_proxy="$HTTPS_PROXY"
export all_proxy="$ALL_PROXY"
export no_proxy="$NO_PROXY"
复现步骤
- 启动 Windows 10,并进入 WSL。
- 在 WSL 中配置代理环境变量。
- 在 WSL 中安装并配置 OpenCodex。
- 执行:
- 通过 Codex 与 GPT 开始对话。
实际结果
Codex 界面持续显示:
Reconnecting... 2/5 (19s • esc to interrupt)
随后请求失败,并显示:
Unexpected status 502 Bad Gateway:
Provider unreachable:
The socket connection was closed unexpectedly.
For more information, pass `verbose: true` in the second argument to fetch(),
url: http://<LOOPBACK_HOST>:<OPENCODEX_PORT>/v1/responses
OpenCodex 日志中出现:
[upstream-retry] connection reset (<UPSTREAM_HOST>) — retrying
请求记录中出现:
{
"provider": "openai",
"status": 502,
"recoveryKinds": ["connection-reset"]
}
对比结果
在相同的 Windows 10 + WSL 环境中执行:
随后安装 Codex shim:
安装 Codex shim 后,通过 Codex 与 GPT 对话可以正常完成。以下错误不再出现:
502 Bad Gateway
connection reset (<UPSTREAM_HOST>)
The socket connection was closed unexpectedly
预期结果
在 Windows 10 + WSL 环境执行 ocx service install 后,通过 Codex 与 GPT 对话应当能够正常完成,行为应当与执行 ocx codex-shim install 时一致。
Reproduction
- Start Windows 10 and open the WSL distribution.
- Configure the proxy environment variables inside WSL.
- Install and configure OpenCodex inside WSL.
- Run:
- Start a conversation with GPT through Codex.
Version
2.26.0
Operating system
Windows 10 22H2, WSL2 2.7.12.0
Provider and model
openai/gpt-5.6-luna
Logs or error output
Screenshots and supporting files
No response
Redacted configuration
Checks
Client or integration
Codex CLI
Area
CLI
Summary
After running
ocx service installin a Windows 10 + WSL environment, Codex requests continuously return502 Bad Gatewayand the Codex client repeatedly reconnects.Environment
This issue occurs on Windows 10 when OpenCodex and Codex run inside WSL.
2.26.0WSL Proxy Configuration
The Windows host runs a local proxy on
<PROXY_PORT>. The proxy environment variables are configured inside WSL using the Windows host address obtained from the WSL default route.The following configuration is used in WSL:
The configuration is persisted in the WSL shell startup file:
Reproduction Steps
Actual Result
The Codex interface continuously displays:
The request then fails with:
The OpenCodex log contains:
The request record contains:
{ "provider": "openai", "status": 502, "recoveryKinds": ["connection-reset"] }Comparison
In the same Windows 10 + WSL environment, run:
Then install the Codex shim:
Expected Result
After running
ocx service installin the Windows 10 + WSL environment, conversations with GPT through Codex should complete successfully, with behavior consistent withocx codex-shim install.环境
该问题发生在 Windows 10 系统中,OpenCodex 和 Codex 运行在 WSL 环境内。
2.26.0WSL 中的代理配置
Windows 主机上的本地代理监听
<PROXY_PORT>端口。WSL 中通过默认路由获取 Windows 主机地址,并设置代理环境变量。WSL 中使用以下配置:
配置持久化在 WSL 的 shell 启动文件中:
复现步骤
实际结果
Codex 界面持续显示:
随后请求失败,并显示:
OpenCodex 日志中出现:
请求记录中出现:
{ "provider": "openai", "status": 502, "recoveryKinds": ["connection-reset"] }对比结果
在相同的 Windows 10 + WSL 环境中执行:
随后安装 Codex shim:
安装 Codex shim 后,通过 Codex 与 GPT 对话可以正常完成。以下错误不再出现:
预期结果
在 Windows 10 + WSL 环境执行
ocx service install后,通过 Codex 与 GPT 对话应当能够正常完成,行为应当与执行ocx codex-shim install时一致。Reproduction
Version
2.26.0
Operating system
Windows 10 22H2, WSL2 2.7.12.0
Provider and model
openai/gpt-5.6-luna
Logs or error output
Screenshots and supporting files
No response
Redacted configuration
Checks