You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
/connect doesnt work for openai when server is remote #8274
when I tried with the tui /connect for openai auth on a vps it resulted in a failed "localhost" connection
However, it works if you do opencode auth login > openai
Report from another use on discord with the same issue:
I’m trying to sign in with an OpenAI pro sub, on a VPS but it’s giving me:
~~~
This site can’t be reached
localhost is currently unreachable.
ERR_CONNECTION_FAILED’’’ after redirecting from the sign in page, it seems like it’s due to the redirect being on a different machine, but I’ve been able to do it with all my other providers so far
It’s for http://localhost:1455/auth/callback?code=…
~~~
Your issue specifically involves the TUI failing to redirect to localhost on a VPS, which is directly related to the redirect URI configuration problem mentioned in these issues.
Feel free to ignore if none of these address your specific case.
I've just closed #8798 in favour of this, but I have made the changes to get this to work, but I think we'd need to update the OpenAI OAuth redirect URLs somehow?
If you reverse proxy OpenCode web (in our case, we're running OpenCode insider a coder workspace), then ChatGPT OAuth doesn't work, because the OAuth server callback is started on another port.
I've made the changes necessary (in my local environment) to make this work, however it looks like this may be a bit more difficult given the OAuth client ID likely has its redirect URL locked down to http://localhost:1455/auth/callback
It would be great to get some more info on this, and whether or not there is a potential other flow we can use (device code?) to get this to work in OpenCode web!
If you’re running OpenCode on a remote server over SSH, the OAuth callback to http://localhost:1455/auth/callback will fail unless you forward the port to your local machine.
What worked for me:
ssh -L 1455:127.0.0.1:1455 user@remote-ip
This forwards your local `localhost:1455` to the remote server’s `localhost:1455`, where OpenCode is listening for the callback.
After reconnecting with this tunnel and re-running the auth flow, the login worked
Hope this helps anyone else running into this
Reacted by Mikec78660, Jason Godsey, SkyWT, doza62, Lauren Lajas, Karol Kozikowski and Mateleo
If you’re running OpenCode on a remote server over SSH, the OAuth callback to http://localhost:1455/auth/callback will fail unless you forward the port to your local machine.
What worked for me:
ssh -L 1455:127.0.0.1:1455 user@remote-ip
This forwards your local localhost:1455 to the remote server’s localhost:1455, where OpenCode is listening for the callback.
After reconnecting with this tunnel and re-running the auth flow, the login worked
Hope this helps anyone else running into this
this worked perfectly for me thank you! just a simple cmd with your ssh command, then copy the link, authenticate, works, close cmd.
@mihnearad What an elegan solution. never thought of it. However i think a uri env variable should be necesary for this types of scenarios. I think callback URI is localhost hardcoded. Another solution would be if openAI supports token verification like claude.
I agree with you. Having a configurable callback URI via an env var or config would be much cleaner for remote or SSH use cases and no workarounds would be needed!
You should now have the option to do the headless version, I'm not using it as a default because the flow is a bit bulkier for most users and may require u to change ur settings for codex subscription since it isn't allowed by default
Activity
github-actions commentedon Jan 13, 2026
This issue might be a duplicate of existing issues. Please check:
Your issue specifically involves the TUI failing to redirect to localhost on a VPS, which is directly related to the redirect URI configuration problem mentioned in these issues.
Feel free to ignore if none of these address your specific case.
rekram1-node commentedon Jan 13, 2026
Yeah I could see how vps could be causing this
iamhenry commentedon Jan 13, 2026
discord thread: https://discord.com/channels/1391832426048651334/1460293126328549446
[-]TUI Openai Auth Broken[/-][+]/connect doesnt work for openai when server is remote[/+]chriswiggins commentedon Jan 16, 2026
I've just closed #8798 in favour of this, but I have made the changes to get this to work, but I think we'd need to update the OpenAI OAuth redirect URLs somehow?
mihnearad commentedon Jan 18, 2026
I managed to get it to work, in my case
If you’re running OpenCode on a remote server over SSH, the OAuth callback to http://localhost:1455/auth/callback will fail unless you forward the port to your local machine.
What worked for me:
This forwards your local `localhost:1455` to the remote server’s `localhost:1455`, where OpenCode is listening for the callback.
After reconnecting with this tunnel and re-running the auth flow, the login worked
Hope this helps anyone else running into this
tangotechhq commentedon Jan 20, 2026
this worked perfectly for me thank you! just a simple cmd with your ssh command, then copy the link, authenticate, works, close cmd.
doza62 commentedon Jan 27, 2026
@mihnearad What an elegan solution. never thought of it. However i think a uri env variable should be necesary for this types of scenarios. I think callback URI is localhost hardcoded. Another solution would be if openAI supports token verification like claude.
mihnearad commentedon Jan 27, 2026
Thanks, I appreciate that!
I agree with you. Having a configurable callback URI via an env var or config would be much cleaner for remote or SSH use cases and no workarounds would be needed!
Hopefully it will be done in a future release
rekram1-node commentedon Jan 29, 2026
You should now have the option to do the headless version, I'm not using it as a default because the flow is a bit bulkier for most users and may require u to change ur settings for codex subscription since it isn't allowed by default