codex auth login fails with "Port 127.0.0.1:1455 is already in use" on WSL
What version of Codex is running?
codex-cli 0.39.0
Which model were you using?
_No response_
What platform is your computer?
Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 x86_64, Microsoft Windows NT 10.0.26100.0 x64
What steps can reproduce the bug?
codex auth login
What is the expected behavior?
The codex auth login command should successfully initiate the authentication process, typically by opening a browser window or providing a URL for the user to visit and authenticate with their OpenAI account. It should not report port conflicts or timeouts.
What do you see instead?
Failed to cancel previous login server: connection timed out
Error logging in: Port 127.0.0.1:1455 is already in use
Additional information
[wsl2]
memory=32GB
processors=6
swap=12GB
swapfile=C:\\temp\\wsl-swap.vhdx
networkingMode=mirrored
[experimental]
hostAddressLoopback=true
netstat -ano | findstr :1455 and lsof -i :1455 return nothing running on these ports.
15 Comments
I encountered the same issue. Until the official fix is released, you can temporarily work around it using the following method:
This avoids the port conflict caused by starting a local callback server until the official fix is released.
I ran into this on Mac with a Linux devcontainer running. Stopping the devcontainer fixed the issue and opened the login.
PS OpenAI, can we be a bit more graceful with the updates breaking authorization? My existing conversations just got 401'd after returning from the weekend.
I experienced the same error on Mac. I was using my local environment, instead of a virtual environment.
The cause was that I already had the Codex extension running on VS Code. Closing VS Code solved the issue.
so how????????
I was also getting this error on windows "An Attempt Was Made to Access a Socket in a Way Forbidden by Its Access Permissions’ (OS Error 10013)"
this fixed both errors on my end
I run multiple devcontainer environment. Codex try to use 1455 port, but if not available, vscode automatically forward it to 1456, 1457... And It cause problem.
Manual auth token prompt should be added.
<img width="1341" height="84" alt="Image" src="https://github.com/user-attachments/assets/570b2b3c-785a-4e94-a8ed-08a1965c9b60" />
Would be nice if we could specify, or be prompted for, an available port to avoid having to shut down vscode when using the cli.
Same here (os error 10013), I fixed it by ➝
I tried to log into Codex CLI on two VS Code devcontainers at the same time as well as outside of the devcontainers and got this error.
Closing stale bugs.
If you run into this condition, it's likely related to your local network configuration (firewalls, VPNs, etc.).
As a workaround, you can use our headless device login mechanism.
Root cause identified for mirrored networking mode users
If you're on WSL2 with
networkingMode=mirroredin.wslconfig, the Windows IP Helper service (iphlpsvc) holds port 1455 at the OS level, making it unavailable to WSL even though nothing WSL-side is using it.Diagnose from WSL:
Permanent fix — switch to NAT mode in
C:\Users\<you>\.wslconfig:Then
wsl --shutdownfrom PowerShell and reopen WSL. NAT mode still relayslocalhostfrom Windows to WSL, so dev server workflows are unaffected.I solved by using the headless device login mechanism after changing to NAT.
I've got an error when tried to login in Powershell. It's definitely a new bug because I didn't have this error before.
I've met the same situation on mac when I have a codex running on Cursor which seemed to be conflict with the offcial codex client. Exit the original cursor codex then everything runs smoothly
I ran into what looks like the same WSL issue and managed to get it working.
In my case the real problem was not an actual port conflict on
127.0.0.1:1455. The login flow from WSL could not launch the browser correctly, so the error was misleading and sent me in the wrong direction.What fixed it for me was making sure the auth URL opens in the Windows browser, not inside the Linux side of WSL.
First, in VS Code / Kilo I had to make sure the external browser setting pointed to a real browser available on Windows. VS Code supports configuring the browser used for opening links via
workbench.externalBrowser, instead of only relying on the system default.Then on Ubuntu/WSL I installed
wslu:After that I verified that WSL could open links in the Windows browser:
Once that worked, the OpenAI login flow started working from WSL too. In my case I did not need extra port forwarding or localhost hacks after that.
So the workaround was basically:
wsluin WSL so Linux-side link opening can forward into the Windows browser.It might be worth teaching Codex to detect WSL and prefer
wslviewautomatically when available. Right now the error points people toward port debugging, even when the real issue is just that WSL cannot launch the browser properly.when I close the cursor,the bug is fixed …