Skip to content

vscode connected to wsl can not sign-in #4562

Closed

Description

@twinrise

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

Activity

  1. added
    bug
    on Oct 1, 2025
  2. vfk-rw commented on Oct 10, 2025

    @vfk-rw

    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.

  3. 23min commented on Oct 14, 2025

    @23min

    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.

  4. e-yi commented on Nov 12, 2025

    @e-yi

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

  5. added
    windows-os
    auth
    on Nov 14, 2025
  6. sharptornadoqsh commented on Nov 20, 2025

    @sharptornadoqsh

    I fix this buy follow steps:

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

    vscode if you do this

    Image Image Image

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

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

    in cursor setting as vscode

    Image

    in windsurf

    Image

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

    Image
  7. Miunmn commented on Nov 27, 2025

    @Miunmn

    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.

  8. sharptornadoqsh commented on Nov 27, 2025

    @sharptornadoqsh
  9. efinal commented on Dec 17, 2025

    @efinal

    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!

  10. sharptornadoqsh commented on Dec 17, 2025

    @sharptornadoqsh
  11. sharptornadoqsh commented on Jan 13, 2026

    @sharptornadoqsh
  12. RektonLee commented on Jan 24, 2026

    @RektonLee

    I fix this buy follow steps:

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

    vscode if you do this

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

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

    in cursor setting as vscode

    Image ### in windsurf Image ## 2、then login you can fix this rember do not turn on wsl ,do not turn on Image

    shutdown wsl2 :this works for vscode、windsurf and cursor

    This Method works for me . Thx~!

  13. niuhuluzhihao commented on Mar 17, 2026

    @niuhuluzhihao

    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

  14. sharptornadoqsh commented on Mar 17, 2026

    @sharptornadoqsh
  15. skye-12138 commented on Apr 23, 2026

    @skye-12138

    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...”

  16. sharptornadoqsh commented on Apr 23, 2026

    @sharptornadoqsh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    authbugwindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions