Skip to content

[FEATURE]: make OAUTH_CALLBACK_HOST configurable #33966

Open

Description

@ryepup

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

#30022 recently changed the oauth server to bind to 127.0.0.1 only.

I use opencode inside a container, and was using docker run -p 19876 to get the browser on my host talking to opencode via http://127.0.0.1:19876.

I would like a new envvar or config option to customize OAUTH_CALLBACK_HOST.

workaround

Use a docker entrypoint with socat to route traffic

#!/usr/bin/env bash
socat TCP-LISTEN:19877,fork,bind=0.0.0.0 TCP:127.0.0.1:19876 &
opencode "$@"

When I need to authenticate, I run docker run -p 19876:19877 --entrypoint=..., with routes the traffic correctly:

flowchart
    subgraph host
        browser
        docker
        subgraph container
            socat
            opencode
        end
    end
    browser -->|127.0.0.1:19876| docker
    docker -->|0.0.0.0:19877| socat
    socat -->|127.0.0.1:19876| opencode
Loading

Activity

  1. github-actions commented on Jun 25, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. ryepup commented on Jun 25, 2026

    @ryepup
    Author

    This is a different oauth flow than #24455, I think it's a separate issue.

  3. wp07e commented on Jul 5, 2026

    @wp07e

    Thank you! Been struggling with this the entire day. I'll use your work around for now.

  4. magnuslarsen commented on Jul 6, 2026

    @magnuslarsen

    I too would like to see this fixed. I have a remote server where I run OpenCode, and authenticate via my laptop. This broke with the hardcoded 127.0.0.1 host

  5. dannykopping commented on Aug 12, 2026

    @dannykopping

    It's becoming more and more essential to run AI agents inside of sandboxes, and listening only on localhost prevents that from being done easily, since the locally-bound port can't be addressed from the outside during the OAuth callback.

  6. ryepup commented on Aug 14, 2026

    @ryepup
    Author

    I can think of two ways to solve this:

  7. tstraley commented on Oct 14, 2026

    @tstraley

    This type of issue could also be solved with headless (paste-code) oauth solution, as brought up in #54495

  8. opencodejr commented on Oct 29, 2026

    @opencodejr
    Contributor

    Thanks for the request and for writing up the socat workaround, @ryepup!

    To restate it: you'd like a config option or environment variable to set the host the MCP OAuth callback listener binds to. When OpenCode runs in a container, sandbox or on a remote host, the browser could then reach the callback through a published port. Since #30022 the listener is bound to 127.0.0.1 only. The current v2 code (packages/core/src/mcp/oauth.ts) also hardcodes 127.0.0.1, and only callback_port and redirect_uri can be configured. Maintainers will consider it.

    Related issues and PRs:

    Until then, your socat entrypoint (or SSH port forwarding for remote hosts) is the way to go.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions