Codex not work in WSL
Resolved 💬 8 comments Opened Dec 5, 2025 by B192186-2021 Closed Mar 16, 2026
💡 Likely answer: A maintainer (etraut-openai, contributor)
responded on this thread — see the highlighted reply below.
What version of Codex is running?
v0.65.0
What subscription do you have?
chatgpt plus
Which model were you using?
gpt-5.1 low
What platform is your computer?
Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 x86_64
What issue are you seeing?
when I say "hello" to codex, then it returns following things:
Reconnecting... 1/5
Reconnecting... 2/5
Reconnecting... 3/5
Reconnecting... 4/5
Reconnecting... 5/5
stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses)
tips:
I can normally chat with codex with same setting in windows powershell. While receive "Reconnecting" all the time in WSL.
What steps can reproduce the bug?
Please install Codex both on Windows and WSL. Then run codex and auth by chatgpt in Windows powershell to receive the auth.json file. Copy and paste it into .codex folder in WSL. Then run codex in WSL.
Tips:
I cannot directly auth in WSL, since it will return a error in the final step of authentication. Error msg:
Token exchange failed: error sending request for url (https://auth.openai.com/oauth/token)
What is the expected behavior?
I wanna use codex in WSL.
Additional information
_No response_
8 Comments
Best practices for WSL(https://developers.openai.com/codex/windows/#windows-experimental-sandbox) cannot work on my PC. Maybe the key issue lies in the ChatGPT authorization process within WSL.
Please use the
/feedbackslash command to upload a session where you're seeing this behavior and post the thread ID here. That will help us understand the conditions that lead to this problem. Thanks!Hi, the issue is still reproducible, and I’ve submitted the log as you suggested.
thread: 019b0236-2098-7562-959b-2aa95471211d
error msg:
stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses)
@B192186-2021, thanks for uploading the session. Unfortunately, that didn't provide much help because the failure occurs before we receive any response from the model.
The behavior you're describing is likely because you've configured WSL to have no (or limited) networking access. Are you able to access other network locations from within WSL?
I'm running into the same issue - works in Windows/pwsh, same error as above in WSL...
/feedback thread id: 019b31ac-bec3-75d0-9648-f44177f1a312
From within my WSL instance, I am able to access other external resources. In our corporate environment, there is a NetSkope VPN/proxy that is replacing the SSL cert...
❯ wget https://openai.com
--2025-12-18 08:46:29-- https://openai.com/
Resolving openai.com (openai.com)... 172.64.154.211, 104.18.33.45
Connecting to openai.com (openai.com)|172.64.154.211|:443... connected.
ERROR: The certificate of ‘openai.com’ is not trusted.
ERROR: The certificate of ‘openai.com’ doesn't have a known issuer.
<img width="521" height="505" alt="Image" src="https://github.com/user-attachments/assets/93e2f5d7-6be1-4464-9eec-42a3af827e16" />
Ok, a little more investigating and I was able to fix my issue (corp. proxy injecting SSL certs) - I installed/trusted the proxy certs in WSL's instance of Firefox as well as the system itself - ``
sudo update-ca-certificates``...Closing stale issue. If you're still seeing problems with the latest version of the Codex CLI, please open a new issue and provide requested details.
Fix: Codex and Claude Code not working in VS Code Remote WSL when VPN is enabled
Context
I was using:
Both Codex and Claude Code worked correctly without the VPN.
As soon as the VPN was enabled, both tools started failing inside WSL / VS Code Remote WSL.
---
Symptoms
Codex error
Codex failed with errors like:
The Codex conversation could not start properly.
Claude Code error
Claude Code failed with errors like:
At first, it looked like an OpenAI / Anthropic / VS Code extension issue, but it was actually caused by WSL2 networking with the VPN.
---
Diagnosis
From Windows PowerShell, with the VPN enabled, the Codex endpoints were reachable:
Both returned:
This
405is expected because those endpoints expectPOST, notHEAD.The important part is that Windows could reach the endpoints through the VPN.
However, from WSL2, the tools were failing or timing out when the VPN was enabled.
So the real issue was:
---
Root cause
The issue was caused by the default WSL2 NAT networking mode interacting badly with the Windows VPN.
With the VPN enabled:
The problem was not Codex itself, Claude Code itself, or VS Code itself.
The problem was the WSL2 networking mode.
---
Fix
Create or edit this Windows file:
Add the following configuration:
Then fully restart WSL:
After restarting WSL, test the Codex endpoints inside WSL:
Expected output:
Again,
405is fine here. It proves that the endpoints are reachable from WSL.After enabling WSL2 mirrored networking, both Codex and Claude Code worked again with the VPN enabled.
---
Codex installation note
If
codexis not installed inside WSL, install it with npm, not snap.Check Node and npm:
Install Codex:
Verify:
Then log in and test:
Avoid installing Codex with snap in this setup:
In my case, installing Codex through npm worked correctly after fixing WSL networking.
---
Final summary
The issue was:
The fix was to enable WSL2 mirrored networking:
Then restart WSL:
After switching WSL2 to mirrored networking, WSL used the VPN path correctly and Codex / Claude Code worked again inside VS Code Remote WSL with the VPN enabled.