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 — desktop: background service spawn fails "port in use" on Windows/WSL2 mirrored networking — app stuck at logo, error not logged · Issue #55907 · anomalyco/opencode

desktop: background service spawn fails "port in use" on Windows/WSL2 mirrored networking — app stuck at logo, error not logged #55907

New issue
Copy link
New issue
Copy link
Closed
Closed
desktop: background service spawn fails "port in use" on Windows/WSL2 mirrored networking — app stuck at logo, error not logged#55907
Copy link

Description

@zhangzp0127
zhangzp0127
opened on Oct 16, 2026
Issue body actions

Summary

On Windows with WSL2 in mirrored networking mode, the desktop app's background service (opencode-cli.exe serve --service) repeatedly fails to start: multiple concurrent spawns race for the fixed managed service port, failed spawns are surfaced as a fatal Desktop IPC handler failed error, and the app gets stuck at the logo. The underlying bind error is never logged to main.log.

Environment

  • Desktop app: 2.0.29 and 2.0.30 (both affected)
  • Bundled CLI: 2.0.29 / 2.0.30 (opencode-cli.exe serve --service)
  • OS: Windows 11 Home x64 (build 10.0.26300)
  • WSL: 3.0.3.0, distro Ubuntu (running), kernel 6.18.54.1-microsoft-standard-WSL2
  • .wslconfig: networkingMode=Mirrored + [experimental] hostAddressLoopback=true
  • A WSL-side shared service (opencode serve --service, v2.0.30) runs inside the distro on 127.0.0.1:49374; mirrored loopback (hostAddressLoopback=true) exposes it to Windows at 127.0.0.1:49374

Reproduction

  1. Install the desktop app on a machine where the WSL distro runs the opencode shared service (or where the managed service port is otherwise occupied on Windows loopback)
  2. Launch the desktop app (cold start, or restart while the previous sidecar is still shutting down)
  3. main.log shows v2 CLI background service starting { reason: 'missing' } — repeated, with no service ready
  4. Windows-side service log shows repeated errors:
    Managed service port <N> on 127.0.0.1 is already in use by another process. Configure another port with \opencode service set port ` ...`
  5. App stuck at logo / error dialog: Desktop IPC handler failed → Server process exited with code 1

Observed on both default ports:

  • 2.0.29 (49374): collides with the WSL-side service exposed on Windows loopback via mirrored networking
  • 2.0.30 (45278): the app's own concurrent spawns race for the port — at least one instance binds and serves (visible in the log: /api/event requests served), while later duplicate spawns fail with 45278 already in use; Service.ensure surfaces the failed duplicate as fatal instead of adopting the serving instance

Expected Behavior

  • Spawn attempts are serialized; a running compatible instance is adopted (or waited on) instead of racing
  • If a spawn fails to bind, the underlying error is logged to main.log and surfaced gracefully (window loads, connection retried) instead of a silent abort / stuck logo

Actual Behavior

  • Service.ensure treats a failed spawn as fatal; the underlying bind error is never written to main.log
  • App stuck at logo; error dialog: UnknownError: An error occurred in Effect.tryPromise → Server process exited with code 1

Additional Context

  • Workaround: an explicit free port in %USERPROFILE%\.config\opencode\service.json ({"port": <free>}) lets the service start
  • Related issues: Desktop: silent abort before window creation when sidecar utilityProcess.fork fails #49562 (silent abort without logging — same pattern), opencode2 became stuck starting its managed background server #41696, [v2 Windows] opencode2 hangs at "Starting background server..." after reinstall #41746
  • Note: a fixed well-known service port also collides with WSL-side bindings under mirrored networking (hostAddressLoopback=true), so a fixed port on Windows collides by design in this environment. Suggest considering an ephemeral service port + registration-file discovery, or excluding ports held by mirrored WSL bindings
  • Suggestion: log the failed spawn's underlying error in main.log — currently the one useful piece of information is the only thing never written anywhere (same as described in Desktop: silent abort before window creation when sidecar utilityProcess.fork fails #49562)

Activity

  1. opencode-agent commented on Oct 16, 2026

    @opencode-agent
    opencode-agentBot
    on Oct 16, 2026 – with OpenCode Agent
    Contributor
    More actions

    Thanks for the detailed report and logs. I couldn't reproduce this here because it needs the Windows desktop app with WSL2 mirrored networking, which this sandbox can't provide. On Linux with 2.0.30, six opencode service start runs at the same time all connected to one service without a port conflict. So the duplicate starts you saw probably come from the desktop app's startup path or from Windows itself, not the shared client. A maintainer with a Windows + WSL2 setup will need to look at it.

    Related issues, most closely related first:

    • service: relaunch fails with "Managed service port already in use" when previous background service has not exited #54267: a new client starts a competing serve --service on the fixed port while the existing service is still alive or booting
    • service: hardcoded default port 49374 locks out any second client on shared loopback (multi-user/WSL mirrored), surfacing only a generic timeout #50672: the fixed default port collides between Windows and WSL under mirrored networking. In 2.0.30 the Windows default moved to 45278, which is why your 2.0.30 failure looks different
    • Desktop: silent abort before window creation when sidecar utilityProcess.fork fails #49562: an earlier (v1) report of a desktop startup failure that is never written to the log

    In the meantime, setting a free port in service.json (or with opencode service set port <port>), as you found, works around it.

  2. neriousy commented on Oct 19, 2026

    @neriousy
    neriousy
    on Oct 19, 2026
    Member
    More actions

    Thanks for the detailed report. Since 2.0.30 the Windows default port (45278) sits inside the usual WSL mirrored reservation (44620–48715), so we'd like to check whether that's part of what you saw:

    1. Does it still happen on Desktop 2.0.32?
    2. The output of wsl cat /proc/sys/net/ipv4/ip_local_port_range while it fails.
    3. Do you have a proxy configured (on Windows, or autoProxy in .wslconfig)?
    4. Does opencode service set port <port outside that range> (with the bundled CLI) fix it?
  3. zhangzp0127 commented on Oct 20, 2026

    @zhangzp0127
    zhangzp0127
    on Oct 20, 2026
    Author
    More actions

    感谢跟进。按你列的 4 点补充信息:

    1) 2.0.32 上是否仍复现:
    在 Desktop 2.0.29(默认 49374)和 2.0.30(默认 45278,来自 #55547)上均复现。2.0.32 未测——桌面在排查过程中被卸载,目前未安装,可以随时重装复测。

    2) 临时端口范围:

    wsl cat /proc/sys/net/ipv4/ip_local_port_range
    → 44620 48715
    

    默认服务端口 45278 正好落在这个范围内,与 #55918 的发现一致。

    3) 代理:
    未配置任何代理——Windows 系统代理 ProxyEnable=0,.wslconfig 中无 autoProxy,也未设置 HTTP(S)_PROXY 环境变量。

    4) service set port 修复测试:
    尚未用桌面内置 CLI 实测 opencode service set port <port outside range>(桌面已卸载)。但等效方案已验证有效:在 %USERPROFILE%\.config\opencode\service.json 显式指定范围外端口({"port": 49376})后,服务可正常启动,桌面恢复可用。

    补充一点:#55918 的独立绑定测试(.NET TcpListener 直接绑定 45278 失败、无任何进程占用、邻近端口正常)与我们观察到的现象完全吻合,支持“镜像模式 HNS 临时端口预留”这一根因判断。如果需要,我可以重装桌面 2.0.32 并实测 service set port 的修复效果后回来同步结果。

  4. echo-ilovech3ss
    added a commit that references this issue on Nov 7, 2026

    fix(cli): scope managed service port remap to WSL with distinct default

    056bfe6
  5. neriousy commented on Nov 19, 2026

    @neriousy
    neriousy
    on Nov 19, 2026
    Member
    More actions

    Fixed by #57428, which moves the Windows default service port to 28894, outside the range WSL mirrored networking reserves. If you still see this on the latest version, comment here and we'll reopen.

  6. neriousy
    closed this as completedon Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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

      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.