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
[Enhancement] Desktop app and terminal should connect to existing server instead of starting a new one when port is already in use #7629
When configuring OpenCode with a custom server configuration specifying a port and hostname, there's a conflict when running multiple OpenCode instances.
Running opencode serve starts the backend server at 0.0.0.0:4096
Opening the OpenCode desktop app or terminal subsequently also attempts to start a server on the same 0.0.0.0:4096
This results in an error because the port is already in use
Expected Behavior
When a user has explicitly configured a specific host and port, OpenCode should:
First check if a backend server is already running on the configured host:port
If a server is already running → connect to it directly
If no server is running → start a new server
Proposed Solutions
Option A: Automatic detection
When both hostname and port are explicitly configured, OpenCode should automatically detect an existing server and connect to it instead of attempting to start a new instance.
Option B: New config flag
Add a new configuration option (e.g., "connectOnly": true or "reuseServer": true) that when enabled:
Prevents starting a new server if one is already running on the configured address
All subsequent OpenCode instances connect to the existing server
Lost changes and session in vscode #6051: Lost changes and session in vscode when switching between CLI and extension - related to multiple instances connecting to same project
While not exact duplicates, these issues all address challenges with running multiple OpenCode instances and server management that your issue proposes to solve through automatic detection and connection reuse.
Feel free to ignore if your specific case differs from these.
Ran into this same issue in a linux setup with 1.2.15.
If the server config block is present, and I run opencode serve to enable remote host connectivity, attempts to run opencode on the machine running opencode serve will simply hang as it loads the opencode.json config file with the server settings.
It would be great if running the TUI would automatically connect to the running opencode serve instance, but picking a different point for its sidecar rather than hanging would better than the current state.
Activity
github-actions commentedon Jan 10, 2026
This issue might be a duplicate of existing issues. Please check:
opencode serverapi #5256: Adding Authentication to opencode server api - related to authentication for remote server accessWhile not exact duplicates, these issues all address challenges with running multiple OpenCode instances and server management that your issue proposes to solve through automatic detection and connection reuse.
Feel free to ignore if your specific case differs from these.
jrmcpeek commentedon Mar 2, 2026
Ran into this same issue in a linux setup with 1.2.15.
If the server config block is present, and I run
opencode serveto enable remote host connectivity, attempts to runopencodeon the machine runningopencode servewill simply hang as it loads the opencode.json config file with the server settings.It would be great if running the TUI would automatically connect to the running
opencode serveinstance, but picking a different point for its sidecar rather than hanging would better than the current state.github-actions commentedon May 2, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.