Unable to complete OAuth login for Codex extension when using github.dev / Codespaces (redirect to localhost fails)
What version of the VS Code extension are you using?
0.4.37
What subscription do you have?
ChatGPT Plus (Codex access enabled)
Which IDE are you using?
GitHub Codespaces (browser-based VS Code) at https://miniature-broccoli-7wp9vx6xq64hrv6r.github.dev/
What platform is your computer?
Running inside GitHub Codespaces (Linux container, VS Code Web) Local client OS: macOS
What issue are you seeing?
I am trying to sign in to the OpenAI Codex VS Code extension inside GitHub Codespaces (browser-based VS Code environment). The authorization flow starts, but the redirect URL always returns to:
http://localhost:1455/auth/callback?code=...&scope=openid+profile+email+offline_access
Since Codespaces is a remote cloud environment and does not expose localhost ports to my browser environment, the extension cannot complete the OAuth exchange and therefore I cannot log in or use Codex.
Expected behavior:
The extension should detect remote environments such as github.dev / Codespaces and use a web-based redirect URI (e.g. https://<workspace>.app.github.dev/ or device_code grant) instead of localhost:1455.
Actual behavior:
OAuth redirect tries to reach local machine localhost, which is not accessible in a remote development environment. As a result, authentication never completes.
What I need:
Guidance on how to authenticate Codex inside github.dev / Codespaces. Is there an official supported redirect URI or alternative login flow (e.g. device code auth or manual API token provisioning)?
Environment:
- GitHub Codespaces (browser VS Code)
- Codex extension
- Remote VS Code Web client
- No access to localhost of the remote environment
What steps can reproduce the bug?
- Open any repository on GitHub.
- Press
.to open the repository in github.dev (browser-based VS Code)
or open it inside GitHub Codespaces.
- Install and enable the OpenAI Codex extension.
- Click "Sign in" in the Codex extension.
- The browser opens the OAuth login page and authentication appears to succeed.
- After confirming access, the redirect goes to:
http://localhost:1455/auth/callback?code=...
- Since the environment is remote (github.dev / Codespaces), localhost is not accessible.
- The authorization never completes and the Codex extension remains unauthenticated.
What is the expected behavior?
_No response_
Additional information
_No response_
13 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Similar issue when using Dev Containers (VSCode server inside a Docker container) for a few days. Unable to log in, the redirect points to localhost:1455, which is not forwarded by the container. Login worked perfectly fine in the same environment a few days ago.
Version: 1.107.0
Commit: 618725e67565b290ba4da6fe2d29f8fa1d4e3622
Date: 2025-12-10T07:43:47.883Z
Electron: 39.2.3
ElectronBuildId: 12895514
Chromium: 142.0.7444.175
Node.js: 22.21.1
V8: 14.2.231.21-electron.0
OS: Linux x64 6.8.0-88-generic
Name: Codex – OpenAI’s coding agent
Id: openai.chatgpt
Description: Codex is a coding agent that works with you everywhere you code — included in ChatGPT Plus, Pro, Business, Edu, and Enterprise plans.
Version: 0.4.50
Publisher: OpenAI
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=openai.chatgpt
Solved it for Dev Containers. It seems VSCode/Docker exported 1455 to 1456 on my machine. I edited the port to 1455 and was able to log in again.
<img width="1405" height="146" alt="Image" src="https://github.com/user-attachments/assets/7edd1af3-6dc3-4d5e-85af-46d27d575ba4" />
In my case I had two separate devcontainers running at once. As @lostcontrol pointed out, port missmatch is the core issue. Codex always expects port 1455 for auth (on the host). In a multi-devcontainer setup, the first codex instance on the first container takes up port 1455, and the other instances are forced to default to 1456, 1457, etc. and the auth fails.
The solution I've came up is to to just store creds on the host, outside of devcontainers and to avoid multi login on each container whatsoever
"mounts": [
"type=bind,source=${localEnv:HOME}/.codex-shared,target=/codex"
],
"remoteEnv": {
"CODEX_HOME": "/codex"
}
The latest version of Codex extension is even more broken than before in Codespace. Before, it would try to complete the authentication process using localhost. You could substitute the host by doing a port export in Codespace. Now the extension just keeps spinning on start-up.
Got the same issue. Been using Cursor to code on a remote computer (w/ the remote ssh extension). Couldn't auth into Codex. Issue was indeed the port 1455 forwarded to 1456. ChatGPT solved it by adding to my .ssh file:
You can then reconnect and verify to the ports tab:
<img width="1201" height="33" alt="Image" src="https://github.com/user-attachments/assets/f518898d-7a43-4210-97f3-44d018995e13" />
And authentication worked right after.
Using your OpenAI API key would be a better alternative, if you have one. This is the approach I used:
Note: You'll need to fund your account on the OpenAI Platform dashboard for this to work, and it's billed from your API balance on a pay-as-you-go basis, not your ChatGPT subscription
It's not actually, if you login to the api it's on usage base with account on subscription base.
Authentication Workaround Steps
Alternative straightforward workaround:
__then reload your workspace.__
But the prompting is limited to CLI and right pane based chat does not work
It does work, have you tried restarting your workspace? Codex CLI shares authentication with the Codex Extension.
I spent way to much time trying to login...
Incredible how every step of the way there is something dumb happening :
Using the Normal sign in : same issue described above
I tried codex login --device-auth
But https://auth.openai.com/codex/device would prompt me for the code, but it expect only Numbers, and need to enter a code with letters
I tried https://auth.openai.com/api/accounts/deviceauth/authorize
It showed :
Enable device code authorization for Codex in ChatGPT Security Settings, then run "codex login --device-auth" again.
I did that, reloaded , and it worked.
Holly balls...