Skip to content

service: managed service fails to start on a second login account (port 49374 hardcoded per channel) #56792

Closed as duplicate

Description

@wheelerfam7-commits

Description

On a single macOS machine with two login accounts, the second account cannot start OpenCode. The managed background service binds a port that is hardcoded per channel (latest/dev/beta/next → 49374), and ports are machine-wide rather than per-user, so only one login account can run a service at a time.

The second account's client fails and exits immediately:

Managed service port 49374 on 127.0.0.1 is already in use by another process.
Configure another port with `opencode service set port <port>` and start the service again.

A workaround exists (opencode service set port <port>), but the fixed default guarantees the collision. Either derive the port per user or fall back to a free port automatically.

Plugins

None.

OpenCode version

2.0.32 (channel=latest, desktop app). The failing process is the app's managed CLI (.../ai.opencode.desktop/cli/2.0.32-arm64/opencode-cli serve --service). A separate 0.0.0-dev-* build present in the same account was not involved.

Steps to reproduce

  1. On macOS, log in as user A and start OpenCode so its managed service is listening on 127.0.0.1:49374 (lsof -nP -iTCP:49374 -sTCP:LISTEN confirms it).
  2. Leave A running. Log in as user B and start OpenCode.
  3. B never opens. ~/.local/share/opencode/log/opencode.log (in B's account) repeats:
level=INFO  message="cli starting" version=2.0.32 channel=latest local=false args="[\"serve\",\"--service\"]" role=cli
level=ERROR message="cli process failed"
  cause="... Managed service port 49374 on 127.0.0.1 is already in use by another process ..."

Expected Behavior

Each login account can run its own OpenCode service — e.g. a per-user default port, or automatic fallback to a free port — instead of a fixed machine-wide 49374.

Actual Behavior

The second account's CLI fails to bind and exits, so the client/app never opens. The only way forward is to manually reassign the port.

Additional Context

  • Hardcoded in the 2.0.32 CLI: if(e==="latest"||e==="dev"||e==="beta"||e==="next") return 49374; if(e==="local") return 49375;
  • Second account has no ~/.config/opencode/service.json and no port setting anywhere, so it necessarily falls back to the default and collides.
  • Workaround that works: in the second account, opencode service set port 49375 (writes ~/.config/opencode/service.json), then start the service. 49375 is free.
  • Found after migrating a second account onto the machine; previously the machine had only one OpenCode account, so the collision could not occur. Not a migration/corruption issue.
  • Possibly related: PR fix(service): handle unusable managed-service ports on Windows #53355 (fix(service): handle unusable managed-service ports on Windows).

Operating System

macOS 26.2 (Darwin 25.2.0, arm64 / Apple Silicon)

Terminal

zsh in Terminal.app (also reproduces from the desktop app)

Activity

  1. opencode-agent commented on Oct 18, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed report and the workaround. I think this is a duplicate of #50672. That issue covers the same root cause: the managed service's default port (49374) is fixed for the whole machine, so a second login account can't bind it. Its thread already includes the two-users-on-one-machine case and the same Managed service port 49374 ... already in use error. On the current dev branch the default is still fixed per channel, with no per-user part and no fallback to a free port.

    Possible duplicates and closely related issues, ordered from most to least likely:

    Until it's fixed, your workaround is the way to go: in the second account, run opencode service set port <free port> and start the service again. A 👍 or a short comment on #50672 noting that this also affects macOS desktop users would help.

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

  2. wheelerfam7-commits commented on Oct 18, 2026

    @wheelerfam7-commits
    Author

    Duplicate of #50672 — confirmed macOS multi-account; added a note there.

  3. opencode-agent commented on Oct 18, 2026

    @opencode-agent
    Contributor

    Thanks for confirming, and for adding the macOS multi-account case to #50672. Further updates will be tracked there. The bot will close this issue as a duplicate as planned. Until it's fixed, opencode service set port <free port> in the second account is still the workaround.

  4. opencode-agent commented on Oct 19, 2026

    @opencode-agent
    Contributor

    Closing this as a duplicate of #50672, which you confirmed, and thanks for adding the macOS multi-account case there. Please follow #50672 for updates on the fixed default port. Until it's fixed, running opencode service set port <free port> in the second account is the workaround.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions