Skip to content

feat(web): add --host option for LAN access#933

Open
itxaiohanglover wants to merge 1 commit into
MoonshotAI:mainfrom
itxaiohanglover:feat/server-host-option
Open

feat(web): add --host option for LAN access#933
itxaiohanglover wants to merge 1 commit into
MoonshotAI:mainfrom
itxaiohanglover:feat/server-host-option

Conversation

@itxaiohanglover

Copy link
Copy Markdown

Problem

kimi web and kimi server run always bind to 127.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

  • Add a --host <host> option to both kimi web and kimi server run (they share buildRunCommand). The default stays 127.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.
  • Thread the host through the background-daemon path: startServerBackground -> ensureDaemon -> spawnDaemonChild now forward --host to the detached daemon child, and resolveDaemonPort probes the requested host. The in-process (--foreground) and --daemon paths already passed host to startServer, so they pick up the new option automatically.
  • The ready banner now reports Network: local only for loopback binds and Network: LAN (<host>) when bound to a non-loopback address.
  • Updated docs/en + docs/zh command reference and added a changeset (@moonshot-ai/kimi-code: patch).
  • Updated/added tests: assert --host is registered on server run and the web alias; verify spawnDaemonChild forwards --host when provided and omits it otherwise; verify the banner advertises LAN reachability for 0.0.0.0.

Validation

  • pnpm --filter @moonshot-ai/kimi-code test -- test/cli/server/server.test.ts
  • Manual: kimi server run --foreground --host 0.0.0.0 then reach the UI from another machine on the LAN; kimi web --host 0.0.0.0 starts the background daemon bound to all interfaces (use kimi server kill first if a loopback daemon is already running).

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-bot

changeset-bot Bot commented Jun 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 495f2b8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

const origin = serverOrigin(lockConnectHost(existing), existing.port);
if (await waitForServerHealthy(origin, REUSE_HEALTH_TIMEOUT_MS)) {
return { origin };

P2 Badge Honor --host before reusing a daemon

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".

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Support LAN access by binding to 0.0.0.0 instead of localhost

1 participant