localhost:5173 / vite-host

Reaching localhost:5173 from your phone or another machine

The dev server listens on localhost by default, so nothing else on the network can reach it — start it with --host (or set server.host) to listen on your LAN address.

Expose it on the network

Vite then prints a second URL with your machine’s LAN address. That is the one you open on the phone, on the same Wi-Fi.

bash
$ npm run dev -- --host

  ➜  Local:   http://localhost:5173/
  ➜  Network: http://192.168.1.24:5173/

Or set it permanently

host: true is the same as 0.0.0.0 — listen on every address the machine has.

vite.config.js
export default defineConfig({
  server: {
    host: true,
  },
})

Know what you just opened

Every device on that network can now reach your dev server, and a dev server serves your source. On your own Wi-Fi that is fine. On conference, hotel or coworking networks it is not. Turn it off when you are done.

It is reachable but the hostname is blocked

If you reach it through a tunnel or a custom hostname and get "Blocked request. This host is not allowed", the network side is already working — that is the separate host allowlist.

  • See: Blocked request. This host is not allowed.

WSL2 needs more than --host

WSL2 runs its own network stack, so listening on all addresses inside WSL does not by itself make the port reachable from other machines on your LAN. Windows port forwarding or mirrored networking mode is what closes that gap. Reaching it from Windows itself usually works out of the box.

Docker: bind inside, map outside

Inside a container, localhost means the container. Without --host the server is unreachable from your machine no matter how you map the ports.

bash
# in the container
vite --host 0.0.0.0

# on your machine
docker run -p 5173:5173 my-app

When another server answers instead

Two known cases, both documented by Vite. With localhost, Node and the browser can resolve to different addresses (IPv4 vs IPv6) — Vite prints the resolved address when it differs from what you asked for. With a wildcard host like 0.0.0.0, a process listening on a specific address takes priority over one listening on the wildcard. If a stale server answers on 5173 and you cannot find it, this is usually why.

# faq

Questions

What does --host do?

It makes the dev server listen on all network addresses instead of localhost only, so other devices can reach it.

Why can my phone not open localhost:5173?

On the phone, localhost is the phone. Use the Network URL Vite prints after --host, and stay on the same network.

Is --host safe?

On a network you trust, yes. On a shared or public network, anyone on it can read your source through the dev server.

Is host: true the same as 0.0.0.0?

Yes, both listen on all addresses.

# next

Related

# sources

Checked against the Vite documentation on 2026-09-11.