Sign-in error when using the remote env in vscode

Resolved 💬 20 comments Opened Aug 29, 2025 by wglassly Closed Sep 16, 2025
💡 Likely answer: A maintainer (gpeal, contributor) responded on this thread — see the highlighted reply below.

What version of the VS Code extension are you using?

0.4.0

Which IDE are you using?

VS Code

What platform is your computer?

Darwin 24.5.0 arm64 arm

What steps can reproduce the bug?

when I use the codex at remote env, click sign-in

<img width="422" height="1222" alt="Image" src="https://github.com/user-attachments/assets/511bc5c3-4f3a-48f9-a0bc-f3002835f1da" />

the browser returns: Token exchange failed: token endpoint returned status 403 Forbidden

<img width="566" height="78" alt="Image" src="https://github.com/user-attachments/assets/fd1add4e-d77e-43c6-af6a-85e64e868456" />

What is the expected behavior?

_No response_

What do you see instead?

_No response_

Additional information

_No response_

View original on GitHub ↗

20 Comments

frondesce · 10 months ago

I hit the same issue in Codespaces.

  • CodeX version: 0.4.0
  • Local CodeX and Web app work fine
  • Only in GitHub Codespaces (remote env) → /wham/environments calls return 403 Forbidden

Workaround:
Forcing the extension to run on the UI/local side instead of the remote host fixes it. Example setting in remote settings.json:

"remote.extensionKind": {
"openai.chatgpt": "ui"
}

After this, CodeX works normally in Codespaces.

godjoem · 10 months ago
Workaround: Forcing the extension to run on the UI/local side instead of the remote host fixes it. Example setting in remote settings.json: "remote.extensionKind": { "openai.chatgpt": "ui" }

~~Works for me, thx a lot.~~
Seems that the extension running in the host can NOT identify the files in the remote server

frondesce · 10 months ago
> Workaround: Forcing the extension to run on the UI/local side instead of the remote host fixes it. Example setting in remote settings.json: > "remote.extensionKind": { > "openai.chatgpt": "ui" > } ~Works for me, thx a lot.~ Seems that the extension running in the host can NOT identify the files in the remote server

This doesn't fit my situation. As shown below, codex can see the file.
It seems that this is not a universal solution, there may be other bugs.

<img width="404" height="415" alt="Image" src="https://github.com/user-attachments/assets/9c9885d0-2fa0-45f6-a581-4fb728ca36fa" />

asw101 · 10 months ago

I also have to workaround this to login to Codex CLI via GitHub Codespaces (e.g. https://github.com/asw101/codespaces ).

This is the workflow I have to follow: https://youtu.be/jVxj-JQOe2Y

  1. Choose Sign in with ChatGPT
  2. Open the external website, https://auth.openai.com/oauth/authorize?...
  3. Authenticate using my SSO
  4. Be redirected to http://localhost:1455/auth/callback?... which throws ERR_CONNECTION_REFUSED
  5. Open the special URL that exposes the forwarded port on :1455 on a public github.dev URL
  6. Copy-paste the domain and replace the localhost:1455 in the prior URL to be able to complete authentication.

I can do this as a power user, but it is very hard for me to recommend this experience to anyone.

ifsheldon · 10 months ago

The most general solution for now is to use ssh port forwarding. Just use ssh to bind the localhost:1455 on the local machine to the localhost:1455 on the remote machine. And then open the link shown on the remote terminal on the local machine. Login and wait for the callback. This is twisted but it works! Ask your _local_ codex if it sounds a bit complex :)

shixian64 · 10 months ago

已解决,需要使用代理启动code

frondesce · 10 months ago
已解决,需要使用代理启动code

Is there a more detailed solution?

shixian64 · 10 months ago

:~$ HTTPS_PROXY=http://:*** HTTP_PROXY=http://:***
NO_PROXY=localhost,127.0.0.1,::1 code
ubuntu 终端 打开code

frondesce @.***> 于2025年9月16日周二 10:57写道:

frondesce left a comment (openai/codex#2869) <https://github.com/openai/codex/issues/2869#issuecomment-3294662818> 已解决,需要使用代理启动code Is there a more detailed solution? — Reply to this email directly, view it on GitHub <https://github.com/openai/codex/issues/2869#issuecomment-3294662818>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/BAJE53V6WEYWBT2CLBQ2GAT3S54DLAVCNFSM6AAAAACFDKRLCOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTEOJUGY3DEOBRHA> . You are receiving this because you commented.Message ID: @.***>
shixian64 · 10 months ago
  • is your vpn network agent

Xian Shi @.***> 于2025年9月16日周二 15:57写道:

:~$ HTTPS_PROXY=http://:*** HTTP_PROXY=http://:* NO_PROXY=localhost,127.0.0.1,::1 code ubuntu 终端 打开code frondesce @.> 于2025年9月16日周二 10:57写道: > frondesce left a comment (openai/codex#2869) > <https://github.com/openai/codex/issues/2869#issuecomment-3294662818> > > 已解决,需要使用代理启动code > > Is there a more detailed solution? > > — > Reply to this email directly, view it on GitHub > <https://github.com/openai/codex/issues/2869#issuecomment-3294662818>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/BAJE53V6WEYWBT2CLBQ2GAT3S54DLAVCNFSM6AAAAACFDKRLCOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTEOJUGY3DEOBRHA> > . > You are receiving this because you commented.Message ID: > @.**> >
gpeal contributor · 10 months ago

This is the same as #2796 which we're working on resolving but for now, you can log in like this

ibnrushd-dev · 9 months ago

Here's how I fixed it:

  1. Open a forwarding port in Github Codespace: 1455, note down the port address it should look something like: https://codespace-name-1455.app.github.dev/
  2. Now type codex in the terminal and it will prompt you to log in to ur Open AI account.
  3. Complete the prompts and you will be asked to enter the one time password.
  4. Next you will end up with: This site can’t be reached | localhost refused to connect.
  5. Once you reach here, edit the first part of the url 'http://localhost:1455/auth/callback?code=' and change it to your code space port url 'https://codespace-name-1455.app.github.dev/' and press enter.
  6. Your terminal will be updated and you will be successfully logged into codex cli.
wu-yc · 9 months ago
I hit the same issue in Codespaces. CodeX version: 0.4.0 Local CodeX and Web app work fine * Only in GitHub Codespaces (remote env) → /wham/environments calls return 403 Forbidden Workaround: Forcing the extension to run on the UI/local side instead of the remote host fixes it. Example setting in remote settings.json: "remote.extensionKind": { "openai.chatgpt": "ui" } After this, CodeX works normally in Codespaces.

这个方法最好

  1. 打开 VS Code 或cursor, Ctrl + Shift + P (或 Cmd + Shift + P)
  2. 输入Preferences: Open Remote Settings (JSON),并进去
  3. 然后添加

"remote.extensionKind": {
"openai.chatgpt": "ui"
}

重启窗口
完成!

ESOU666 · 9 months ago
> > Workaround: Forcing the extension to run on the UI/local side instead of the remote host fixes it. Example setting in remote settings.json: > > "remote.extensionKind": { > > "openai.chatgpt": "ui" > > } > > > ~Works for me, thx a lot.~ Seems that the extension running in the host can NOT identify the files in the remote server This doesn't fit my situation. As shown below, codex can see the file. It seems that this is not a universal solution, there may be other bugs. <img alt="Image" width="404" height="415" src="https://private-user-images.githubusercontent.com/35183040/484643204-9c9885d0-2fa0-45f6-a581-4fb728ca36fa.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NjExMjExODgsIm5iZiI6MTc2MTEyMDg4OCwicGF0aCI6Ii8zNTE4MzA0MC80ODQ2NDMyMDQtOWM5ODg1ZDAtMmZhMC00NWY2LWE1ODEtNGZiNzI4Y2EzNmZhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTEwMjIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUxMDIyVDA4MTQ0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTdhZTRmNzIxMzFiNDBkY2E1MDBlNjI1NmFkY2ViMzRlMTJkZTg1MjdmOWE3YTFlZDliMzFiMjUzNzhhMDBjODEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.PVLbDRvJ6AwNrlBn7S-3puCQ1kkjtDBgmBdAEJDIWFE">

No, this doesn't mean the extention can actually see the files in your remote server. It can only see the path of you file which you are currently looking at. It cannot read the file itself. Via this method, the extension is actually working on you local machine, so it can only access the files in your local computer. When you ask codex to explain the code on the remote server to you, it says that it can't access the file. And what the extension actually sees is the file in your local computer! Check the photo below.

<img width="1562" height="1184" alt="Image" src="https://github.com/user-attachments/assets/b725d46a-c303-44ca-959b-4a0e22789c47" />

ESOU666 · 9 months ago
> I hit the same issue in Codespaces. > > CodeX version: 0.4.0 > Local CodeX and Web app work fine > * Only in GitHub Codespaces (remote env) → /wham/environments calls return 403 Forbidden > > Workaround: Forcing the extension to run on the UI/local side instead of the remote host fixes it. Example setting in remote settings.json: > "remote.extensionKind": { > "openai.chatgpt": "ui" > } > After this, CodeX works normally in Codespaces. 这个方法最好 1. 打开 VS Code 或cursor, Ctrl + Shift + P (或 Cmd + Shift + P) 2. 输入Preferences: Open Remote Settings (JSON),并进去 3. 然后添加 "remote.extensionKind": { "openai.chatgpt": "ui" } 重启窗口 完成!

不,这并不意味着扩展可以实际查看您远程服务器上的文件。它只能看到您当前查看的文件路径,无法读取文件本身。通过这种方式,codex实际上是以本地vscode ui 的方式在您的本地计算机上工作,因此它只能访问您本地计算机上的文件。当您要求Codex为您解释远程服务器上的代码时,它会说无法访问该文件。而扩展实际上看到的是您本地计算机上的文件!请查看下面的照片。

<img width="1562" height="1184" alt="Image" src="https://github.com/user-attachments/assets/5ac20ba6-13bc-49c4-b056-601b66d6b99e" />

Maddan-Holdings · 8 months ago
> 已解决,需要使用代理启动code Is there a more detaile solution?
Maddan-Holdings · 8 months ago
> 已解决,需要使用代理启动code Is there a more detailed solution? I already tried this, it got flagged as malicious..... lol
Maddan-Holdings · 8 months ago
> 已解决,需要使用代理启动code Is there a more detailed solution?

I already tried this, It got flagged as malicious...lol

Maddan-Holdings · 8 months ago
> 已解决,需要使用代理启动code Is there a more detailed solution?
I already tried this, it got flagged for being malicious...lol
songqi1207 · 8 months ago
> > 已解决,需要使用代理启动code > > > Is there a more detailed solution? > I already tried this, it got flagged for being malicious...lol

me too lol

kaiwenxue0 · 3 months ago
Here's how I fixed it: 1. Open a forwarding port in Github Codespace: 1455, note down the port address it should look something like: https://codespace-name-1455.app.github.dev/ 2. Now type codex in the terminal and it will prompt you to log in to ur Open AI account. 3. Complete the prompts and you will be asked to enter the one time password. 4. Next you will end up with: This site can’t be reached | localhost refused to connect. 5. Once you reach here, edit the first part of the url 'http://localhost:1455/auth/callback?code=' and change it to your code space port url 'https://codespace-name-1455.app.github.dev/' and press enter. 6. Your terminal will be updated and you will be successfully logged into codex cli.

Note. This method does not work now.