GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — service: hardcoded default port 49374 with no fallback and a silent hang when it's unavailable · Issue #52234 · anomalyco/opencode

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

New issue
Copy link
New issue
Copy link
Closed as duplicate
Closed as duplicate
service: hardcoded default port 49374 with no fallback and a silent hang when it's unavailable#52234
Copy link
Assignees
kitlangton
Labels
pending closetriaging

Description

@CyberTodBG
CyberTodBG
opened on Sep 30, 2026
Issue body actions

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

  • v2.0.20 hard-codes the port: release channels return 49374, local returns 49375, others derive a value; there is no fallback or port scan.
  • The override is undocumented: service set accepts port, but service set --help omits it and the Network docs cover only service set env.
  • The desktop app collides with the CLI service on the same port and hangs identically.
  • Possibly related: service: hardcoded default port 49374 locks out any second client on shared loopback (multi-user/WSL mirrored), surfacing only a generic timeout #50672, cli: background service startup reports generic timeout, hiding port-in-use root cause #49009.

Activity

  1. github-actions
    assigned
    kitlangton
    on Sep 30, 2026
  2. github-actions
    added
    needs:complianceThis means the issue will auto-close after 2 hours.
    on Sep 30, 2026
  3. github-actions commented on Sep 30, 2026

    @github-actions
    github-actionsBot
    on Sep 30, 2026 – with GitHub Actions
    Contributor
    More actions

    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.

  4. github-actions commented on Sep 30, 2026

    @github-actions
    github-actionsBot
    on Sep 30, 2026 – with GitHub Actions
    Contributor
    More actions

    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.

  5. github-actions
    removed
    needs:complianceThis means the issue will auto-close after 2 hours.
    on Sep 30, 2026
  6. github-actions commented on Sep 30, 2026

    @github-actions
    github-actionsBot
    on Sep 30, 2026 – with GitHub Actions
    Contributor
    More actions

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

  7. CyberTodBG commented on Sep 30, 2026

    @CyberTodBG
    CyberTodBG
    on Sep 30, 2026
    Author
    More actions

    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.

    Reacted by alekseyHunter
  8. alekseyHunter commented on Oct 7, 2026

    @alekseyHunter
    alekseyHunter
    on Oct 7, 2026
    More actions

    Bump

  9. neriousy commented on Oct 19, 2026

    @neriousy
    neriousy
    on Oct 19, 2026
    Member
    More actions

    A few follow-ups to help separate the causes behind this message:

    1. Does this still happen on 2.0.32?
    2. Are you on WSL mirrored or NAT networking (%USERPROFILE%\.wslconfig), and what does cat /proc/sys/net/ipv4/ip_local_port_range show?
    3. Are HTTP_PROXY/HTTPS_PROXY/NO_PROXY set inside WSL, or is autoProxy on?
    4. Is OpenCode Desktop or a Windows CLI running on the host at the same time?
    5. When it happened, was the port held by a process you could see (ss -ltnp | grep 49374), or was nothing listening?
  10. opencodejr commented on Oct 28, 2026

    @opencodejr
    opencodejrBot
    on Oct 28, 2026
    Contributor
    More actions

    Thanks for the detailed report! I think this is a duplicate of #50672, which covers the same problem. The managed service binds the hardcoded default port 49374 with no fallback. When that port can't be bound, the client keeps retrying and shows only a generic wait or timeout, not the child's "port already in use … opencode service set port <port>" error. Your case is a Hyper-V/WSL reserved port range rather than a second client, but the cause and the fix you're asking for (a fallback port, or failing fast with the real error) are the same.

    Possible duplicates and closely related issues, ordered by likelihood:

    • service: hardcoded default port 49374 locks out any second client on shared loopback (multi-user/WSL mirrored), surfacing only a generic timeout #50672: hardcoded port 49374 with no fallback on WSL/shared loopback, with only a generic timeout shown (same problem)
    • TUI hangs at "Starting background server..." when Desktop app is installed #57978: TUI hangs at Starting background server... when the Desktop app is installed and uses 49374 (same hang, and the Desktop/CLI port collision you mention)
    • desktop: background service spawn fails "port in use" on Windows/WSL2 mirrored networking — app stuck at logo, error not logged #55907: Desktop app on Windows/WSL2 mirrored networking stuck because of "port in use", and the error isn't logged
    • cli: background service startup reports generic timeout, hiding port-in-use root cause #49009 (closed): the port-in-use cause was hidden behind a generic startup timeout
    • Starting background server... Error: Background service failed to start #57032: the same "Managed service port … already in use" error, shown to the user
    • service: relaunch fails with "Managed service port already in use" when previous background service has not exited #54267 / service: "Managed service port ... already in use" when a healthy service is registered under a different XDG_STATE_HOME #56708: "port already in use" caused by a previous or differently registered service

    As a workaround, you can move the service off the blocked range with opencode service set port <port> (picking a port outside the Hyper-V excluded ranges shown by netsh interface ipv4 show excludedportrange protocol=tcp). Your points about service set --help and the Network docs not mentioning port are useful additions to #50672.

    The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.

  11. opencodejr
    added
    pending close
    triaging
    on Oct 28, 2026
  12. opencodejr
    closed this as duplicateon Oct 29, 2026
  13. opencodejr commented on Oct 29, 2026

    @opencodejr
    opencodejrBot
    on Oct 29, 2026
    Contributor
    More actions

    We haven't heard back since the duplicate notice, so I'm closing this as a duplicate of #50672. That issue covers the same problem: the background service uses the fixed default port 49374 with no fallback, and when the port can't be bound the real "port already in use" error is hidden behind a hang or timeout. Please follow #50672 for updates. Your details about Hyper-V/WSL reserved port ranges, and about the port option missing from service set --help and the Network docs, would be useful there.

    In the meantime, opencode service set port <port> with a port outside the excluded ranges (netsh interface ipv4 show excludedportrange protocol=tcp) should get you unblocked. If your problem turns out to be different from #50672, reply here and we can reopen it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @kitlangton
    kitlangton

Labels

pending closetriaging

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.