vscode connected to wsl can not sign-in

Resolved 💬 15 comments Opened Oct 1, 2025 by twinrise Closed Jan 13, 2026

What version of Codex is running?

latest

Which model were you using?

gpt-4.1

What platform is your computer?

wsl

What steps can reproduce the bug?

My VS Code is connected to the VS Code Server on WSL. After installing the Codex plugin, when I try to log in, the browser opens the login page. After I log in, it can’t redirect back to the plugin. This seems to happen because the authorization callback URL is generated inside WSL and uses localhost. After logging in, the browser tries to call back to localhost to notify the plugin of success, but it fails since it points to the WSL host. Can this bug be fixed? Or could you implement the same authorization approach as Claude Code?

What is the expected behavior?

when i login in browser, should notify codex plugin, and can do work in plugin

What do you see instead?

_No response_

Additional information

_No response_

View original on GitHub ↗

15 Comments

vfk-rw · 9 months ago

I also have this issue with attempting to log in to codex running on a remote headless server. I enter in the url in browser, log into openai, but it times out. There should be way to login when the machine the web browser is on is not the machine codex is running on.

zsr71 · 9 months ago

i meet the same issue
2025-10-12 21:09:54.539 [error] Error fetching https://ab.chatgpt.com/v1/rgstr?k=client-sYWqzCYMRkUg4DqqiZcR5DGTNl2iD7zNJY0HoeDLzxR&st=javascript-client-react&sv=3.25.5&t=1760274592504&sid=a61a839f-fdc3-4143-9144-17a8eff3ff28&ec=1001&gz=1: TypeError: fetch failed
2025-10-12 21:09:55.983 [error] CLI: Token exchange error: error sending request for url (https://auth.openai.com/oauth/token)

<img width="1704" height="307" alt="Image" src="https://github.com/user-attachments/assets/7b18c583-345b-496b-970f-4b31e78c0802" />

23min · 9 months ago

I was having the same issue, suddenly, after it had been working fine for a few days.
I asked ChatGPT. It said I could try adding the following in my devcontainer.json:

  "forwardPorts": [
    1455
  ],
  "portsAttributes": {
    "1455": {
      "label": "Codex OAuth callback"
    }
  },
  {
    "runArgs": ["-p", "1455:1455"]
  }

No idea why it stopped working. I think it was when I tried using Codex in a second container.

e-yi · 8 months ago

Fixed the same issue by ensuring the WSL network works in the mirrored mode.

sharptornadoqsh · 8 months ago

I fix this buy follow steps:

1、shutdown wsl2 :this works for vscode、windsurf and cursor

vscode if you do this

<img width="1266" height="213" alt="Image" src="https://github.com/user-attachments/assets/597a5a3c-000c-44c3-9247-d740f33375ad" />

<img width="1347" height="576" alt="Image" src="https://github.com/user-attachments/assets/28cdec01-33ef-488f-a9d8-ce6324c3003b" />

<img width="2337" height="804" alt="Image" src="https://github.com/user-attachments/assets/fbbfa5df-1a7b-4881-b9bf-2880800b0938" />

in settins.json file turn off the wsl2 as follows:

{
    "cline.vsCodeLmModelSelector": {},
    "chatgpt.runCodexInWindowsSubsystemForLinux": false,
    "chatgpt.cliExecutable": ""
}

in cursor setting as vscode

<img width="1932" height="735" alt="Image" src="https://github.com/user-attachments/assets/7203a11d-a125-477f-95b6-4b8eea474210" />

in windsurf

<img width="1314" height="366" alt="Image" src="https://github.com/user-attachments/assets/106acb98-9410-4d87-aff9-22f8ad8746b4" />

2、then login you can fix this rember do not turn on wsl ,do not turn on

<img width="429" height="744" alt="Image" src="https://github.com/user-attachments/assets/2ee61b8c-d0b9-4e86-ae0f-ec6526c6db7b" />

Miunmn · 7 months ago

I was able to fix this issue with the following steps
(assuming you already have the WSL extension installed in VS Code):

  1. Open VS Code on Windows (do not open it via WSL yet) and install the Codex extension.
  2. Sign in with OpenAI from the Windows VS Code. At this point Codex should work normally in the Windows environment.
  3. Open PowerShell and navigate to:

$env:USERPROFILE\.codex\auth.json

Open that file and copy its JSON contents.

  1. In your Linux (WSL) terminal, create the same directory and file:


mkdir -p ~/.codex
nano ~/.codex/auth.json

Paste the JSON you copied from Windows and save the file.

  1. Now open VS Code in WSL (for example, with code . from your Linux terminal). Codex should be authenticated and working correctly.
sharptornadoqsh · 7 months ago

您好,您的邮件我已经收到,我会尽快处理

efinal · 7 months ago
I was able to fix this issue with the following steps (assuming you already have the WSL extension installed in VS Code): 1. Open VS Code on Windows (do _not_ open it via WSL yet) and install the Codex extension. 2. Sign in with OpenAI from the Windows VS Code. At this point Codex should work normally in the Windows environment. 3. Open PowerShell and navigate to: $env:USERPROFILE\.codex\auth.json Open that file and copy its JSON contents. 4. In your Linux (WSL) terminal, create the same directory and file: mkdir -p ~/.codex nano ~/.codex/auth.json Paste the JSON you copied from Windows and save the file. 5. Now open VS Code in WSL (for example, with code . from your Linux terminal). Codex should be authenticated and working correctly.

it works!

sharptornadoqsh · 7 months ago

您好,您的邮件我已经收到,我会尽快处理

sharptornadoqsh · 6 months ago

您好,您的邮件我已经收到,我会尽快处理

RektonLee · 5 months ago
I fix this buy follow steps: ## 1、shutdown wsl2 :this works for vscode、windsurf and cursor ### vscode if you do this <img alt="Image" width="822.6666870117188" height="138.40625" src="https://private-user-images.githubusercontent.com/132986137/516717931-597a5a3c-000c-44c3-9247-d740f33375ad.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NjkyMzYyMzgsIm5iZiI6MTc2OTIzNTkzOCwicGF0aCI6Ii8xMzI5ODYxMzcvNTE2NzE3OTMxLTU5N2E1YTNjLTAwMGMtNDRjMy05MjQ3LWQ3NDBmMzMzNzVhZC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMTI0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDEyNFQwNjI1MzhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT03N2MzZmI4MTZkNmEzYTg5ZWNkYmVjY2Y1ZTE0NDIzN2ZmN2JhNDliYjk3ZmI3ZjM2NTZkYmJhZjYzYmU1ZjQ3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.4fTYRXwS1dudZCNaG4_p4lwAoxnTLKWQsTbojvOY0pg"> <img alt="Image" width="822.6666870117188" height="351.78125" src="https://private-user-images.githubusercontent.com/132986137/516718192-28cdec01-33ef-488f-a9d8-ce6324c3003b.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NjkyMzYyMzgsIm5iZiI6MTc2OTIzNTkzOCwicGF0aCI6Ii8xMzI5ODYxMzcvNTE2NzE4MTkyLTI4Y2RlYzAxLTMzZWYtNDg4Zi1hOWQ4LWNlNjMyNGMzMDAzYi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMTI0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDEyNFQwNjI1MzhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kOTJjNGZlNGNmNGFhMDliYzk1NzUzZTVhZjdhNjY1M2NjOTAyOTc0NjFmNGVjM2RjNjgxMTRjMDlmNTNlMGRiJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.fbMX6VslYTGzGzuQPX54kUSm8gRnjQW26YoF5Ut0BIk"> <img alt="Image" width="822.6666870117188" height="283.0208435058594" src="https://private-user-images.githubusercontent.com/132986137/516718337-fbbfa5df-1a7b-4881-b9bf-2880800b0938.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NjkyMzYyMzgsIm5iZiI6MTc2OTIzNTkzOCwicGF0aCI6Ii8xMzI5ODYxMzcvNTE2NzE4MzM3LWZiYmZhNWRmLTFhN2ItNDg4MS1iOWJmLTI4ODA4MDBiMDkzOC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMTI0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDEyNFQwNjI1MzhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01MDgzMjc5Y2U5YjRjZGJmNTBhMTBiZjczY2JhZjllOTdmNTA4MDNjYTcwODRhMWNlZTM0NWU3NWJkYWViZTBmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.eH674fsj0dpOMU6qgeGO-oGdQhd8GUGTh9H91lLHrw4"> in settins.json file turn off the wsl2 as follows: `` { "cline.vsCodeLmModelSelector": {}, "chatgpt.runCodexInWindowsSubsystemForLinux": false, "chatgpt.cliExecutable": "" } `` ### in cursor setting as vscode <img alt="Image" width="822.6666870117188" height="312.96875" src="https://private-user-images.githubusercontent.com/132986137/516719871-7203a11d-a125-477f-95b6-4b8eea474210.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NjkyMzYyMzgsIm5iZiI6MTc2OTIzNTkzOCwicGF0aCI6Ii8xMzI5ODYxMzcvNTE2NzE5ODcxLTcyMDNhMTFkLWExMjUtNDc3Zi05NWI2LTRiOGVlYTQ3NDIxMC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMTI0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDEyNFQwNjI1MzhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0xZTljYTJjZDJlYWE5ZDFiMjE1ODFiZDEyMjI5ZDU2ZTcxYmQwY2Q5NzE2NTU4ZGM0NDM0ZmFhM2I1YzQ0MzZiJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.pU6mps2WV54S2s12_yBk6XS5QPxt8gb4HTwldLYOinU"> ### in windsurf <img alt="Image" width="822.6666870117188" height="229.1354217529297" src="https://private-user-images.githubusercontent.com/132986137/516720136-106acb98-9410-4d87-aff9-22f8ad8746b4.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NjkyMzYyMzgsIm5iZiI6MTc2OTIzNTkzOCwicGF0aCI6Ii8xMzI5ODYxMzcvNTE2NzIwMTM2LTEwNmFjYjk4LTk0MTAtNGQ4Ny1hZmY5LTIyZjhhZDg3NDZiNC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMTI0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDEyNFQwNjI1MzhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yZDE1NjA3Mjc2ZTEzODAxOWU5ODc3Yzc5YWQ4MDQ2Y2ZkYTg4ZmNlNTdkNjliMjYxNjBhY2IyZTU2Mzk4N2JiJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.GpYDpizIdaTuvIr5_OQQlItmSPPbc2BgGsSShTXp7fY"> ## 2、then login you can fix this rember do not turn on wsl ,do not turn on <img alt="Image" width="429" height="744" src="https://private-user-images.githubusercontent.com/132986137/516721293-2ee61b8c-d0b9-4e86-ae0f-ec6526c6db7b.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NjkyMzYyMzgsIm5iZiI6MTc2OTIzNTkzOCwicGF0aCI6Ii8xMzI5ODYxMzcvNTE2NzIxMjkzLTJlZTYxYjhjLWQwYjktNGU4Ni1hZTBmLWVjNjUyNmM2ZGI3Yi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMTI0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDEyNFQwNjI1MzhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yZWE5YTJkODhhYjEzMzk1ZGNiNjE1ODFhMTc4YTgzM2NmNTRkYTJlMDEzMDlhMTViYWJlYzAyZGQ1MmM1ODVhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.SU5rjTk4GgIl8rlAEFTH4FLii9Dz_ISuf_weZmDUh28">

shutdown wsl2 :this works for vscode、windsurf and cursor

This Method works for me . Thx~!

niuhuluzhihao · 4 months ago
> I was able to fix this issue with the following steps (assuming you already have the WSL extension installed in VS Code): > > 1. Open VS Code on Windows (do _not_ open it via WSL yet) and install the Codex extension. > 2. Sign in with OpenAI from the Windows VS Code. At this point Codex should work normally in the Windows environment. > 3. Open PowerShell and navigate to: > $env:USERPROFILE\.codex\auth.json > Open that file and copy its JSON contents. > 4. In your Linux (WSL) terminal, create the same directory and file: > mkdir -p ~/.codex nano ~/.codex/auth.json > Paste the JSON you copied from Windows and save the file. > 5. Now open VS Code in WSL (for example, with code . from your Linux terminal). Codex should be authenticated and working correctly. it works!

modify a little.
1-2、same
3、notepad $env:USERPROFILE\.codex\auth.json
4、mkdir -p ~/.codex vi ~/.codex/auth.json
5、the same
it works +1

sharptornadoqsh · 4 months ago

您好,您的邮件我已经收到,我会尽快处理

skye-12138 · 2 months ago
> > I was able to fix this issue with the following steps (assuming you already have the WSL extension installed in VS Code): > > > > 1. Open VS Code on Windows (do _not_ open it via WSL yet) and install the Codex extension. > > 2. Sign in with OpenAI from the Windows VS Code. At this point Codex should work normally in the Windows environment. > > 3. Open PowerShell and navigate to: > > $env:USERPROFILE\.codex\auth.json > > Open that file and copy its JSON contents. > > 4. In your Linux (WSL) terminal, create the same directory and file: > > mkdir -p ~/.codex nano ~/.codex/auth.json > > Paste the JSON you copied from Windows and save the file. > > 5. Now open VS Code in WSL (for example, with code . from your Linux terminal). Codex should be authenticated and working correctly. > > > it works! modify a little. 1-2、same 3、notepad $env:USERPROFILE.codex\auth.json 4、mkdir -p ~/.codex vi ~/.codex/auth.json 5、the same it works +1

It’s not working for me. It keeps showing “Reconnecting...”

sharptornadoqsh · 2 months ago

您好,您的邮件我已经收到,我会尽快处理