Sign in with ChatGPT does not work (windows wsl)

Resolved 💬 15 comments Opened May 19, 2025 by thejjw Closed Aug 7, 2025

What version of Codex is running?

_No response_

Which model were you using?

_No response_

What platform is your computer?

_No response_

What steps can reproduce the bug?

So I thought I should give codex cli a go after reading this:

We’re also making it much easier to connect your developer account to Codex CLI. Instead of manually generating and configuring an API token, you can now sign in with your ChatGPT account and select the API organization you want to use. We’ll automatically generate and configure the API key for you. Plus and Pro users who sign in to Codex CLI with ChatGPT can also begin redeeming $5 and $50 in free API credits, respectively, later today for the next 30 days.

https://openai.com/index/introducing-codex/

And to my disappointment the experience is not ideal

I install @openai/codex and try sign in with chatgpt, progressing on web browser and only to get this error in the end [^1]

So I go get api key instead and put it, only to get unavailable... error.

user@redacted:~$ codex
Sign in with ChatGPT to generate an API key or paste one you already have.
[use arrows to move, enter to select]

❯ Sign in with ChatGPT
  Paste an API key (or set as OPENAI_API_KEY)

Opening login page in your browser: https://auth.openai.com/oauth/authorize?response_type=code&client_id=app_EMoamEEZ73f0CkXaXp7hrann&redirect_uri=http%3A%2F%2Flocalhost%3A1455%2Fauth%2Fcallback&scope=openid+profile+email+offline_access&code_challenge=iJyH4pnAJJVkqiPh73YieBpRbFApBT-GeWsnnc7z_Uc&code_challenge_method=S256&id_token_add_organizations=true&state=ec9f114603695805626a8ee62c107a22e26037136d61e98e27f5aba91e70c9b0


(   ●  ) Waiting for authentication… ctrl + c to quit
^C
user@redacted:~$
user@redacted:~$ codex
Paste your OpenAI API key and press <Enter>:
********************************************************************************************************************************************************************
The model "codex-mini-latest" does not appear in the list of models available to your account. Double-check the spelling (use
  openai models list
to see the full list) or choose another model with the --model flag.
user@redacted:~$ openai models list
openai: command not found

After all, why does it suggest openai command for those who just installed codex package? at least it could say install openai via some other package, or even better could offer the functionality within itself or lead me to some other webpage that i can check online.

I thought openai products could offer experiences better than this...please improve.

Thanks.

---
[^1]: !Image

What is the expected behavior?

_No response_

What do you see instead?

_No response_

Additional information

_No response_

View original on GitHub ↗

15 Comments

vladlearns · 1 year ago

Works for me in wsl, added docs here: https://github.com/openai/codex/pull/1015

thejjw · 1 year ago

@vladlearns
good to hear it works for you, doesn't for me--ends up with localhost ERR_CONNECTION_REFUSED error when i tried again with codex --login. i hope it provides better way than relying on localhost...or fix it somehow while relying on localhost mechanism (like how github recognizes login from github mobile app to authenticate)

vladlearns · 1 year ago
@vladlearns good to hear it works for you, doesn't for me--ends up with localhost ERR_CONNECTION_REFUSED error when i tried again with codex --login. i hope it provides better way than relying on localhost...or fix it somehow while relying on localhost mechanism (like how github recognizes login from github mobile app to authenticate)

may you please provide the details re your sys
!Image

thejjw · 1 year ago

it's Linux 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux...but don't bother actually. i think they just decided to give api credit to everyone. codex openai login never worked but they filled $5 free credit on the web and when i used api key instead it worked.
thanks.

drawal1 · 1 year ago

Here's what I get trying codex login with windows wsl2:

-----------------

codex login
Starting local login server on http://localhost:1455
If your browser did not open, navigate to this URL to authenticate:

https://auth.openai.com/oauth/authorize?response_type=code&client_id=REDACTED&redirect_uri=http%3A%2F%2Flocalhost%3A1455%2Fauth%2Fcallback&scope=openid+profile+email+offline_access&code_challenge=REDACTED&code_challenge_method=S256&id_token_add_organizations=true&state=REDACTED
/usr/bin/xdg-open: 882: x-www-browser: not found
/usr/bin/xdg-open: 882: firefox: not found
/usr/bin/xdg-open: 882: iceweasel: not found
/usr/bin/xdg-open: 882: seamonkey: not found
/usr/bin/xdg-open: 882: mozilla: not found
/usr/bin/xdg-open: 882: epiphany: not found
/usr/bin/xdg-open: 882: konqueror: not found
/usr/bin/xdg-open: 882: chromium: not found
/usr/bin/xdg-open: 882: chromium-browser: not found
/usr/bin/xdg-open: 882: google-chrome: not found
Error logging in: login_with_chatgpt subprocess failed:
/usr/bin/xdg-open: 882: www-browser: not found
/usr/bin/xdg-open: 882: links2: not found
/usr/bin/xdg-open: 882: elinks: not found
/usr/bin/xdg-open: 882: links: not found
/usr/bin/xdg-open: 882: lynx: not found
/usr/bin/xdg-open: 882: w3m: not found
xdg-open: no method available for opening 'https://auth.openai.com/oauth/authorize?response_type=code&client_id=REDACTED&scope=openid+profile+email+offline_access&code_challenge=REDACTED&code_challenge_method=S256&id_token_add_organizations=true&state=REDACTED'

codex-maintainers · 11 months ago

Thank you for the feedback! We're primarily focused on the native/Rust implementation of Codex CLI. Please try again on the latest version, and if the issue persists, let us know.

cheema-corellian · 11 months ago
Thank you for the feedback! We're primarily focused on the native/Rust implementation of Codex CLI. Please try again on the latest version, and if the issue persists, let us know.

The latest version has only partially fix this issue. You still cannot use the TUI to login. It does not show the URL you need to login. It does show you the URL after the operation has failed. And by that time it is of no use.

Typing "codex login" however does work. It does the right thing and provides the URL you need for login.

nonprofittechy · 11 months ago
Here's what I get trying codex login with windows wsl2: codex login Starting local login server on http://localhost:1455 If your browser did not open, navigate to this URL to authenticate: https://auth.openai.com/oauth/authorize?response_type=code&client_id=REDACTED&redirect_uri=http%3A%2F%2Flocalhost%3A1455%2Fauth%2Fcallback&scope=openid+profile+email+offline_access&code_challenge=REDACTED&code_challenge_method=S256&id_token_add_organizations=true&state=REDACTED /usr/bin/xdg-open: 882: x-www-browser: not found /usr/bin/xdg-open: 882: firefox: not found /usr/bin/xdg-open: 882: iceweasel: not found /usr/bin/xdg-open: 882: seamonkey: not found /usr/bin/xdg-open: 882: mozilla: not found /usr/bin/xdg-open: 882: epiphany: not found /usr/bin/xdg-open: 882: konqueror: not found /usr/bin/xdg-open: 882: chromium: not found /usr/bin/xdg-open: 882: chromium-browser: not found /usr/bin/xdg-open: 882: google-chrome: not found Error logging in: login_with_chatgpt subprocess failed: /usr/bin/xdg-open: 882: www-browser: not found /usr/bin/xdg-open: 882: links2: not found /usr/bin/xdg-open: 882: elinks: not found /usr/bin/xdg-open: 882: links: not found /usr/bin/xdg-open: 882: lynx: not found /usr/bin/xdg-open: 882: w3m: not found xdg-open: no method available for opening 'https://auth.openai.com/oauth/authorize?response_type=code&client_id=REDACTED&scope=openid+profile+email+offline_access&code_challenge=REDACTED&code_challenge_method=S256&id_token_add_organizations=true&state=REDACTED'

Hi, I did a new install of codex on WSL2 and I'm experiencing exactly this same behavior. The locally running server doesn't seem to start.

codex@native doesn't seem to have an option to login with ChatGPT credentials?

bsturk · 11 months ago

experiencing the same thing, switched over to WSL since I couldn't get headless going. Also the native one can't do any sorta of login from what I can tell.

cheema-corellian · 11 months ago

@bsturk @nonprofittechy Did you guys try typing in "codex login"? That should give you a login URL that you can copy/paste to a browser. It is not a fix, but a workaround.

nonprofittechy · 11 months ago

After typing "codex login" with codex@native, this is what I get:

<img width="1579" height="865" alt="Image" src="https://github.com/user-attachments/assets/f47a47c2-6707-44c5-a9bd-7ce1874407b4" />

Per @bsturk I suppose that's not a surprise.

However, reinstalling the node version and then running codex login does work! The instructions I had followed before said to use codex --login which opened the client without a chance for me to visit the login URL. Thanks for that tip.

akoievroman · 10 months ago

As a workaround.
You can select login in browser, proceed to the end with an error, and copy the key from the URL.
Then, cancel login in the console or IDE and select API key instead, and paste the key that you got earlier.

profplum700 · 8 months ago

I was having the same issue and had success running simply codex login, logged in with my credentials, then started codex as usual and it didn't ask me to login and I could start using it.

mrgares · 8 months ago

I found that the issue occurs because Codex inside WSL2 only waits for the sign-in flow to happen inside WSL. The workaround that made it work for me was:

  1. Install Firefox inside WSL.
  2. Run Firefox from the command line:

firefox &

  1. Start the Codex extension sign-in and complete it using the Firefox window from step 2.
mohamed-mahmoud-kyloe · 7 months ago
I found that the issue occurs because Codex inside WSL2 only waits for the sign-in flow to happen inside WSL. The workaround that made it work for me was: 1. Install Firefox inside WSL. 2. Run Firefox from the command line: firefox & 3. Start the Codex extension sign-in and complete it using the Firefox window from step 2.

Confirmed this works thank you!