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
OPENCODE_SERVER_PASSWORD in env prevents user from working in TUI #8173
It would be desirable to be able to start opencode in the tui and also keep the web gui open (for notification sounds, checking in from other devices when networking is set up, personal preferences about using tui and web-gui concurrently, ...)
Plugins
No response
OpenCode version
1.1.16
Steps to reproduce
Run OPENCODE_SERVER_PASSWORD='secure-password' opencode
This issue is sadly not fixed, could you please reopen the issue?
Setting the env variables for server password still leads to the TUI crashing / not starting:
OPENCODE_SERVER_PASSWORD='test' OPENCODE_SERVER_USERNAME="opencode" bun dev . --hostname localhost --port 4096
$ bun run --cwd packages/opencode --conditions=browser src/index.ts . --hostname localhost --port "4096"
^[[?1016;2$y^[[?2027;0$y^[[?2031;0$y^[[?1004;2$y^[[?2004;2$y^[[?2026;0$y^[[1;1R^[[1;1R^[[4;315;1351t^[[<35;27;8MUnauthorized
OPENCODE_SERVER_PASSWORD='test' bun dev . --hostname localhost --port 4096
$ bun run --cwd packages/opencode --conditions=browser src/index.ts . --hostname localhost --port "4096"
^[[?2027;0$y^[[?2031;0$y^[[?1004;2$y^[[?2004;2$y^[[?2026;0$y^[[1;1R^[[1;1R^[[4;315;1351tUnauthorized
➜ opencode git:(dev) 2027;0$y2031;0$y1004;2$y2004;2$y2026;0$yRR;315;1351t
Currently not sure why previously thought that this issue was solved. Maybe something changed in the codebase elsewhere in the meantime OR I probably just forgot to provide "--hostname" and "--port" flags when checking - a few version ago opencode changed its behaviour about not starting a server instance that way anymore and therefore doesnt crash.
and I wanted to test access to the server with username and password. It is for me not important, it was more important to provide it for future users of my app, but until it is not merged upstream, I will and test the merged version. Hopefully this will be soon so that things can be chained together.
Sorry.. it was dummy I did not notice your message and that the PR was already merged. I am running the with the dev version compiled today: 0.0.0-dev-fork-202602021439
The merged PR only handled the case when starting opencode + an rpc server. When an http server is started (due to using hostname and/or port) the auth headers are still missing -> we get the Unauthorized error.
Furthermore the new PR also solves the same issue when using the attach command and for plugin clients too.
To furthermore test that the TUI attach command is solved following test can be done:
Terminal 1 [start server process]:
OPENCODE_SERVER_PASSWORD="test" bun dev serve --hostname 127.0.0.1 --port 4096
Terminal 2 [attach TUI to existing server]:
OPENCODE_SERVER_PASSWORD="test" bun dev attach http://127.0.0.1:4096
In the current dev branch this both yields "Unauthorized". In the branch of the new PR this works as someone would expect by starting the OpenCode client successfully.
Thanks a lot. The new PR #9095 also says "merged" ... but then I should be already running with this, no? I need to check carefully the structure of opencode repo. I am now running on the latest dev branch.
Thanks a lot. The new PR #9095 also says "merged" ... but then I should be already running with this, no? I need to check carefully the structure of opencode repo. I am now running on the latest dev branch.
No that PR is not merged? Does github cache pull requests? Was it maybe merged in the last few seconds / minutes? If that is the case, then this patch is not released yet.
Activity
github-actions commentedon Jan 13, 2026
This issue might be a duplicate of existing issues. Please check:
opencode serverapi #5256: [FEATURE]: Adding Authentication toopencode serverapiFeel free to ignore if none of these address your specific case.
LeonMueller-OneAndOnly commentedon Jan 14, 2026
This issue is sadly not fixed, could you please reopen the issue?
Setting the env variables for server password still leads to the TUI crashing / not starting:
Currently not sure why previously thought that this issue was solved. Maybe something changed in the codebase elsewhere in the meantime OR I probably just forgot to provide "--hostname" and "--port" flags when checking - a few version ago opencode changed its behaviour about not starting a server instance that way anymore and therefore doesnt crash.
alberti42 commentedon Feb 4, 2026
I have the same problems. Is there any fix now?
LeonMueller-OneAndOnly commentedon Feb 4, 2026
This open PR #9095
fixed the issue.
R44VC0RP commentedon Feb 4, 2026
Can you provide a repro so I can test it @LeonMueller-OneAndOnly as we have already merged #8179, as well as @alberti42
alberti42 commentedon Feb 4, 2026
Awesome! I love it. I created an integration of opencode in the zsh prompt for interactive usage
https://github.com/alberti42/Zsh-Opencode-Tab
and I wanted to test access to the server with username and password. It is for me not important, it was more important to provide it for future users of my app, but until it is not merged upstream, I will and test the merged version. Hopefully this will be soon so that things can be chained together.
Thanks a lot for the quick reply!
alberti42 commentedon Feb 4, 2026
Sorry.. it was dummy I did not notice your message and that the PR was already merged. I am running the with the dev version compiled today: 0.0.0-dev-fork-202602021439
I start the server with this script
like this from my $HOME:
and then I try to attach to the server in a different shell like this:
I also tried directly:
but same "unauthorized" message.
Do I do anything wrong? Or likely the problem is still upstream?
alberti42 commentedon Feb 4, 2026
Even simpler to reproduce the issue:
replies:
We can test
# Terminal B: prove server auth works curl -i http://127.0.0.1:4097/global/health curl -i -u andrea:123456 http://127.0.0.1:4097/global/healthresulting in
And finally
producing the error
LeonMueller-OneAndOnly commentedon Feb 4, 2026
The merged PR only handled the case when starting opencode + an rpc server. When an http server is started (due to using hostname and/or port) the auth headers are still missing -> we get the Unauthorized error.
Furthermore the new PR also solves the same issue when using the attach command and for plugin clients too.
In the description of the new PR #9095
Test command:
OPENCODE_SERVER_PASSWORD="test" bun dev . --hostname 127.0.0.1 --port 4096
LeonMueller-OneAndOnly commentedon Feb 4, 2026
To furthermore test that the TUI attach command is solved following test can be done:
Terminal 1 [start server process]:
OPENCODE_SERVER_PASSWORD="test" bun dev serve --hostname 127.0.0.1 --port 4096
Terminal 2 [attach TUI to existing server]:
OPENCODE_SERVER_PASSWORD="test" bun dev attach http://127.0.0.1:4096
In the current dev branch this both yields "Unauthorized". In the branch of the new PR this works as someone would expect by starting the OpenCode client successfully.
alberti42 commentedon Feb 4, 2026
Thanks a lot. The new PR #9095 also says "merged" ... but then I should be already running with this, no? I need to check carefully the structure of
opencoderepo. I am now running on the latestdevbranch.LeonMueller-OneAndOnly commentedon Feb 4, 2026
No that PR is not merged? Does github cache pull requests? Was it maybe merged in the last few seconds / minutes? If that is the case, then this patch is not released yet.