Skip to content

/connect doesnt work for openai when server is remote #8274

Closed

Description

@iamhenry

Description

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=…
~~~

Plugins

No response

OpenCode version

1.1.18

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Jan 13, 2026
  2. github-actions commented on Jan 13, 2026

    @github-actions
    Contributor

    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.

  3. rekram1-node commented on Jan 13, 2026

    @rekram1-node
    Contributor

    Yeah I could see how vps could be causing this

  4. iamhenry commented on Jan 13, 2026

    @iamhenry
    Author
  5. changed the title [-]TUI Openai Auth Broken[/-] [+]/connect doesnt work for openai when server is remote[/+] on Jan 13, 2026
  6. chriswiggins commented on Jan 16, 2026

    @chriswiggins

    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!

  7. mihnearad commented on Jan 18, 2026

    @mihnearad

    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:

    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

  8. tangotechhq commented on Jan 20, 2026

    @tangotechhq

    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:

    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.

  9. doza62 commented on Jan 27, 2026

    @doza62

    @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.

  10. mihnearad commented on Jan 27, 2026

    @mihnearad

    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

  11. rekram1-node commented on Jan 29, 2026

    @rekram1-node
    Contributor
    Image

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingopentuiThis relates to changes in v1.0, now that opencode uses opentui

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions