Skip to content

service: hardcoded default port 49374 with no fallback and a silent hang when it's unavailable #52234

Description

@CyberTodBG

Summary

When the background service's default port (49374 on release channels) is unavailable, the TUI hangs on Starting background server... indefinitely instead of choosing another port or reporting the bind failure. On WSL2/Hyper-V this happens unpredictably because the host can reserve ranges covering that port.

Environment

  • opencode v2.0.20, latest (binary at /root/.opencode/bin/opencode)
  • Linux 5.15 WSL2 (Windows host), /bin/bash, TERM=xterm-256color
  • Plugins: -opencode-pty, cc-safety-net@latest; CLI plugins opencode-stats, ssh-remote, devices

Reproduction

  1. Make 49374 unbindable (another listener, or a WSL/Hyper-V dynamic port exclusion covering it).
  2. Run opencode.
  3. The TUI stays on Starting background server... and never reaches a session.

Expected Behavior

Bind a free port automatically, or fail fast with a visible error naming the port and the opencode service set port <port> remedy.

Actual Behavior

The child service emits the real error:

Managed service port ${port} on ${host} is already in use by another process.
Configure another port with `opencode service set port <port>` and start the service again.

…but the client captures that stderr, prints only Starting background server..., and retries with backoff (spawnDelay 5000, maxSpawnDelay 30000, promiseTimeout 120000).

Additional Context

Activity

  1. github-actions commented on Sep 30, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • Please condense the unusually long, repetitive description. Keep the concise failure summary, reproduction steps, and relevant environment details, and remove repeated port-conflict explanations.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


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

    • #50672: reports the same hard-coded port 49374 conflict and background-service startup failure when another client shares the loopback.
    • #49009: reports a port bind conflict being hidden behind a generic background-service startup timeout.

    If you believe this was flagged incorrectly, please let a maintainer know.

  2. github-actions commented on Sep 30, 2026

    @github-actions
    Contributor

    Thanks for the update. The description still repeats the same port-conflict/fallback explanation across Summary, Actual Behavior, and Additional Context, and Suggested Fixes restates Expected Behavior. Please condense those sections so each fact appears once while keeping the reproduction steps and relevant environment details.

  3. github-actions commented on Sep 30, 2026

    @github-actions
    Contributor

    Thanks for updating the issue with the reproduction steps and environment details!

  4. CyberTodBG commented on Sep 30, 2026

    @CyberTodBG
    Author

    Related to #50672 (same underlying cause: hard-coded 49374, no port fallback). Keeping this open as a distinct report because it covers two cases that issue does not:

    • WSL2/Hyper-V reserved ranges. The Windows host can dynamically reserve a range that includes 49374, so the port is unbindable even when nothing else is listening on it.
    • Desktop app vs. CLI service on the same host. Both want the same default port, so whichever starts second hangs with no message.

    #50672 describes the same defect for the shared-loopback / second-client case.

  5. alekseyHunter commented on Oct 7, 2026

    @alekseyHunter

    Bump

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