Skip to content

[FEATURE]: Improve UX for Port Conflicts - Show Clear Error Instead of Freezing #19272

Closed as not planned

Description

@wzzyj

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

Summary
When launching multiple OpenCode instances with a fixed server port configured, the second instance can freeze without any feedback. This creates confusion and makes it appear as though the tool is unresponsive or single-session only.


Problem
If a user configures a fixed port (e.g. "server": { "port": 4096}) and then starts a second OpenCode instance:

  • The port is already in use by the first instance
  • The second instance attempts to bind to the same port
  • Instead of failing gracefully, the process appears to hang/freeze with no message

Important:
Even when running with maximum verbosity:

opencode --log-level DEBUG

there is no output, error, or diagnostic message indicating that a port conflict has occurred.

This results in:

  • Poor developer experience (unclear what went wrong)
  • Misleading behavior (looks like OpenCode does not support multiple sessions)
  • Debugging difficulty (even DEBUG logs provide no signal)
  • Time wasted investigating unrelated causes

Expected Behavior
When the configured port is already in use, OpenCode should:

  1. Fail fast instead of hanging
  2. Display a clear, actionable error message, e.g.:
Error: Port 4096 is already in use.

Another OpenCode instance may already be running.
You can:
- Stop the existing instance
- Use a different port (e.g. --port 4097)
- Remove the fixed port from your config to allow auto-assignment
  1. Ensure the error is visible at all log levels, including default and DEBUG

Proposed Enhancements (Optional)

  • Add a --port auto fallback mode:

    • If the configured port is busy, automatically pick the next available port
  • Emit explicit logs during server startup (e.g. “binding to port…”)

  • Detect and display the PID/process holding the port (if feasible)

  • Add a pre-flight port availability check before attempting to start


Impact
This change would:

  • Prevent confusion for new users
  • Improve reliability perception
  • Make DEBUG logging actually useful for troubleshooting
  • Reduce support/debugging overhead
  • Align behavior with standard CLI/server UX expectations

Environment

  • OpenCode version: 1.3.0
  • OS: Linux
  • Config:
{
  "server": {
    "port": 4096
  }
}

Repro Steps

  1. Configure a fixed port in config.json
  2. Start OpenCode in one folder
  3. Start OpenCode in another folder
  4. Observe second instance freezing with no output
  5. Retry with --log-level DEBUG → still no indication of port conflict

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Mar 26, 2026
  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 26, 2026
  3. github-actions commented on Mar 26, 2026

    @github-actions
    Contributor

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

  4. assigned and unassigned on Apr 26, 2026
  5. removed
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  6. github-actions commented on Jul 5, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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