cli: pair QR code encodes localhost link when server listens on 0.0.0.0
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- cli, networking
Research direction
Start at the opencode pair command and trace how it selects the URL for the QR code when it prints both loopback and LAN links. The issue gives a reproducible setup and a workaround using --url; compare those outputs to find the selection point. Done when the default QR encodes a link reachable from another device on the LAN.
Written by the indexing model from the issue text.
Description
Summary
When the background service listens on all interfaces (hostname 0.0.0.0), opencode pair prints two one-time links (loopback and LAN IP) but the QR code encodes the 127.0.0.1 link, which can never be reached from another device — so scanning it with a phone on the same network always fails.
Environment
- opencode version: v2.0.27 (latest channel)
- OS: Darwin 25.6.0 (darwin arm64), macOS MacBook Pro
- Terminal: Ghostty (TERM_PROGRAM=ghostty, TERM=xterm-ghostty, COLORTERM=truecolor)
- Shell: /bin/zsh
- Install/channel: latest release
- Active plugins: none found in config
Reproduction
opencode service set hostname 0.0.0.0thenopencode service start.- Run
opencode pair. - Observe the output: two links are printed — one to
http://127.0.0.1:<port>/auth/connect/...and one tohttp://<lan-ip>:<port>/auth/connect/.... - Scan the QR code with a phone on the same LAN (or decode it).
Expected Behavior
The QR code should encode the link reachable from other devices — i.e., the LAN IP link when bound to 0.0.0.0. At minimum, it should not encode the loopback address, which is unreachable by definition from any remote device.
Actual Behavior
The QR encodes http://127.0.0.1:<port>/auth/connect/.... Scanning it with a phone opens a page on the phone itself and fails; the user must manually retype the second printed URL to pair.
Sample output (token redacted):
Open a link to connect. Links work once and expire in 5 minutes.
http://127.0.0.1:49374/auth/connect/MG_...
http://192.168.x.x:49374/auth/connect/MG_...
Additional Context
- Consistently reproducible whenever the service is bound to a non-loopback hostname.
- Workaround that confirms intent:
opencode pair --url http://<lan-ip>:<port>prints only the LAN link, and the QR then encodes it correctly — so the fix likely just needs the default QR payload to prefer the non-loopback link when multiple are printed.
- Dominant language
- TypeScript
- Stars
- 213k
- Forks
- 28.4k
- Avg merge
- 8h 51m
- Merged PRs (30d)
- 289
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from anomalyco/opencode
-
reproduced
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
anomalyco/opencode#55369 · 1 comment ·
Maintainers usually reply within 1 day
-
reproduced
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
anomalyco/opencode#55351 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 72/100
anomalyco/opencode#55285 · 2 comments ·
Maintainers usually reply within 1 day
-
opencode on clean macos zsh .export path not working because it append and it fails because no ~/.zshrc filePossibly taken @fihaaade claimed this today. Openreproduced
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
anomalyco/opencode#55068 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
anomalyco/opencode#54919 · 1 comment ·
Maintainers usually reply within 1 day
All issues in anomalyco/opencode
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
status:approved type:bug
Difficulty 1/5 Under an hour Newbie friendliness 70/100
egdev6/quorb#109 · 1 comment ·
Maintainers usually reply within 1 day
-
stage:4
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
ilan-pinto/roaring-lions#598 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Frontmatter next to `src:` is applied to every imported slide, not only the first (undocumented)Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day