GeezerVison is showing github.com — [FEATURE]: make OAUTH_CALLBACK_HOST configurable · Issue #33966 · anomalyco/opencode
[FEATURE]: make OAUTH_CALLBACK_HOST configurable #33966DescriptionFeature 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
Activitygithub-actions commented on Jun 25, 2026 This issue might be a duplicate of existing issues. Please check:
ryepup commented on Jun 25, 2026 This is a different oauth flow than #24455, I think it's a separate issue. wp07e commented on Jul 5, 2026 Thank you! Been struggling with this the entire day. I'll use your work around for now. magnuslarsen commented on Jul 6, 2026 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 dannykopping commented on Aug 12, 2026 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. ryepup commented on Aug 14, 2026 I can think of two ways to solve this:
- quick & dirty:
const OAUTH_CALLBACK_HOST = process.env.OPENCODE_OAUTH_CALLBACK_HOST || "127.0.0.1"; - no other config works this way
- slow & clean: expand the config schema to allow setting it there, requires more design and consensus, and some more plumbing code. to get the current config into
packages/opencode/src/mcp/oauth-callback.ts. In this case my best guess is an optional "host" arg to McpOAuthCallback.ensureRunning, and expand the Oauth schema to have an optional callbackHost next to callbackPort. We'd want to add both callback* options to https://opencode.ai/docs/mcp-servers#oauth-options.
tstraley commented on Oct 14, 2026 This type of issue could also be solved with headless (paste-code) oauth solution, as brought up in #54495 opencodejr commented on Oct 29, 2026 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.
neriousy commented on Nov 19, 2026 This should be covered by #61706, which takes a different approach than a configurable host.
When OpenCode runs over SSH, in a container or on a remote server, the browser can't reach the local callback after you sign in, so it shows a page that doesn't load. Copy that page's URL from the address bar and paste it into the sign-in prompt:
http://127.0.0.1:52817/callback?code=...&state=...
The prompt appears in /mcps, in opencode mcp auth, and in the sign-in dialog of the desktop and web app. The pasted URL goes through the same checks as a normal browser redirect. See MCP servers → Browser on another machine in the docs.
Closing this for now. If your setup still needs the callback to bind to a different host, let us know and we'll reopen it.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|