feat(web): add --host option for LAN access#933
Conversation
Add a --host option to `kimi web` and `kimi server run` so the server can bind to a specific IP or 0.0.0.0 for LAN/remote access. The default remains 127.0.0.1 (loopback) for backward compatibility and security. Fixes MoonshotAI#908
🦋 Changeset detectedLatest commit: 495f2b8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
kimi-code/apps/kimi-code/src/cli/sub/server/daemon.ts
Lines 260 to 262 in 495f2b8
When a background daemon is already live, this path returns it before checking whether its recorded bind host matches the newly requested --host. In the common case where a user previously ran kimi web and then runs kimi web --host 0.0.0.0, the command reuses the loopback daemon instead of starting or rejecting for a LAN-bound one, so the new option silently has no effect until the user manually kills the daemon. Please compare the lock host with the requested host, or surface a clear error telling the user to stop the existing daemon.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Problem
kimi webandkimi server runalways bind to127.0.0.1(loopback), so the web UI cannot be reached from other machines. This blocks remote access over Tailscale/VPN, access from other devices on the same LAN, CI/CD scenarios that need to reach the service remotely, and WSL2 accessing a Windows-hosted service. There was previously no way to override the bind host.Fixes #908
What changed
--host <host>option to bothkimi webandkimi server run(they sharebuildRunCommand). The default stays127.0.0.1(loopback) for backward compatibility and security; pass--host 0.0.0.0(or any interface IP) to expose the server on the LAN.startServerBackground->ensureDaemon->spawnDaemonChildnow forward--hostto the detached daemon child, andresolveDaemonPortprobes the requested host. The in-process (--foreground) and--daemonpaths already passedhosttostartServer, so they pick up the new option automatically.Network: local onlyfor loopback binds andNetwork: LAN (<host>)when bound to a non-loopback address.docs/en+docs/zhcommand reference and added a changeset (@moonshot-ai/kimi-code: patch).--hostis registered onserver runand thewebalias; verifyspawnDaemonChildforwards--hostwhen provided and omits it otherwise; verify the banner advertises LAN reachability for0.0.0.0.Validation
pnpm --filter @moonshot-ai/kimi-code test -- test/cli/server/server.test.tskimi server run --foreground --host 0.0.0.0then reach the UI from another machine on the LAN;kimi web --host 0.0.0.0starts the background daemon bound to all interfaces (usekimi server killfirst if a loopback daemon is already running).