# localhost:5173: Vite's dev server port, why it won't load, and how to open it elsewhere

December 6, 2026, The Expose team

`localhost:5173` is the address of Vite's development server. 5173 is Vite's default port. When you run `npm run dev` in a React, Vue, Svelte or Laravel project that uses Vite, the terminal prints:

```text
  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
```

Open `http://localhost:5173` in a browser on the same computer and you see your app. The second line tells you the dev server only listens on your own machine. Your phone, a colleague's laptop and the rest of the internet can't reach it until you start Vite with `--host` or share it another way.

If the page doesn't load, find what you see in this table:

| What you see | What it means | Fix |
|---|---|---|
| "This site can't be reached" or `ERR_CONNECTION_REFUSED` | Nothing listens on port 5173 | Run `npm run dev` and open the URL from the `Local:` line |
| `Local: http://localhost:5174/` | Another process had 5173, so Vite took the next free port | Stop the other server, or [set `strictPort`](#why-vite-started-on-5174-instead-of-5173) |
| `localhost:5173` works, `127.0.0.1:5173` doesn't | Vite listens on the IPv6 address `::1` only | Open `localhost`, or [start Vite with `--host 127.0.0.1`](#works-on-localhost5173-but-not-on-1270015173) |
| `Network: use --host to expose` | Other devices can't connect | [`--host` or a LAN share](#network-use-host-to-expose-and-what-host-does) |
| `Blocked request. This host ("…") is not allowed.` | Vite's host check, added in 6.0.9, 5.4.12 and 4.5.6 | [Add the hostname to `server.allowedHosts`](#blocked-request-this-host-is-not-allowed) |
| A page titled "Laravel Vite" | In a Laravel app, Vite only serves assets | [Open the app's own URL](#laravel-your-app-is-not-on-port-5173), such as `my-app.test` |
| Your phone can't open `localhost:5173` | On the phone, `localhost` is the phone | [`expose share http://localhost:5173 --lan --qr-code`](#open-localhost5173-on-your-phone-or-another-computer) |

## Why Vite uses port 5173

Vite 3 changed the default port. Vite 2 started on [port 3000](https://expose.dev/blog/localhost-3000). The [Vite 3 announcement](https://vite.dev/blog/announcing-vite3) says "the default dev server port is now 5173 and the preview server listening at 4173. This change ensures Vite will avoid collisions with other tools." Next.js, for example, also starts on port 3000.

You'll often read that 5173 spells VITE in digits: 5 for V, 1 for I, 7 for T, 3 for E. The announcement doesn't explain the number itself.

To go back to port 3000, or use any other port, set `server.port`:

```js
// vite.config.js
import { defineConfig } from 'vite';

export default defineConfig({
  server: {
    port: 3000,
  },
});
```

For one run, pass the port on the command line instead. With npm, the `--` sends the flag to Vite rather than to npm:

```bash
npm run dev -- --port 3000
```

## Why localhost:5173 refuses to connect

"Refused to connect" means no program listens on that port. Vite isn't broken. The browser found nothing there. Check these in order:

1. **The dev server isn't running.** Vite stops when you close its terminal or press Ctrl+C. Run `npm run dev` and keep that terminal open.
2. **Vite started on another port.** Read the `Local:` line. If it says 5174 or 5175, open that URL. [The next section](#why-vite-started-on-5174-instead-of-5173) explains why.
3. **You ran the preview server.** `vite preview` and `npm run preview` listen on [port 4173](#localhost4173-is-vite-preview), not 5173.
4. **Vite runs in Docker or a dev container.** Inside a container, `localhost` is the container itself, so a published port finds nothing listening. Start Vite with `--host` so it listens on all of the container's addresses. Vite's [troubleshooting guide](https://vite.dev/guide/troubleshooting) adds a case for VS Code dev containers: VS Code's port forwarding doesn't support IPv6, so you may need `server.host: '127.0.0.1'`.
5. **You typed `https://`.** Vite serves plain HTTP unless you configured `server.https`, so `https://localhost:5173` fails with an SSL error. Use `http://localhost:5173`.

## Why Vite started on 5174 instead of 5173

Vite moves to the next free port when 5173 is taken. Vite's [server options](https://vite.dev/config/server-options#server-port) say: "if the port is already being used, Vite will automatically try the next available port so this may not be the actual port the server ends up listening on." The terminal shows it:

```text
Port 5173 is in use, trying another one...

  ➜  Local:   http://localhost:5174/
```

The process on 5173 is usually another Vite server: a second project, or a terminal you forgot about. Find it.

On macOS and Linux:

```bash
lsof -i :5173
```

On Windows:

```text
netstat -ano | findstr :5173
```

The output shows the process ID. Stop that process, or switch to its terminal and press Ctrl+C.

### Make Vite fail instead of moving: strictPort

A moving port breaks everything that has 5173 written into it: an OAuth redirect URI, a CORS allowlist in your API, a tunnel you started with `expose share http://localhost:5173`. Set `strictPort` and Vite exits with an error instead of picking another port:

```js
// vite.config.js
import { defineConfig } from 'vite';

export default defineConfig({
  server: {
    port: 5173,
    strictPort: true,
  },
});
```

With 5173 taken, Vite now stops with `Port 5173 is already in use`. The same works for one run with `npm run dev -- --strictPort`.

Laravel projects mostly don't need this. The Laravel Vite plugin writes the address Vite really listens on to `public/hot`, and Laravel's `@vite` directive reads it, so the page follows Vite to 5174. Under Laravel Sail, the plugin sets `strictPort: true` itself.

## localhost:4173 is vite preview

`vite preview` serves your production build from the `dist` folder on port 4173. Run `vite build` first, or nothing is there to preview. Like the dev server, the preview server moves to the next free port when 4173 is taken.

The preview options mirror the dev server's: `preview.port`, `preview.strictPort`, `preview.host` and `preview.allowedHosts`. The last three default to their `server.*` values, as listed in Vite's [preview options](https://vite.dev/config/preview-options). Everything below about `--host` and blocked hosts applies to `vite preview` as well.

## Works on localhost:5173 but not on 127.0.0.1:5173

This is a question of which address Vite listens on. By default Vite listens on `localhost`, and the operating system decides what `localhost` means. It has two addresses: `127.0.0.1` for IPv4 and `::1` for IPv6.

Node.js 17 changed the order in which it returns them. The [Vite 3 migration guide](https://v3.vite.dev/guide/migration.html) explains: "Node.js under v17 normally resolves `localhost` to `127.0.0.1`". On newer Node.js versions, `localhost` can resolve to `::1` first. Vite then listens on `::1` only. Your browser's request for `localhost:5173` finds it. A request for `127.0.0.1:5173` goes to the IPv4 address, where nothing listens.

You have two fixes:

- Open `http://localhost:5173`, which is the address Vite prints.
- Make Vite listen on IPv4 when a tool needs `127.0.0.1`, such as a proxy, a test runner or an OAuth redirect URI:

```bash
npm run dev -- --host 127.0.0.1
```

Or in `vite.config.js`:

```js
export default defineConfig({
  server: {
    host: '127.0.0.1',
  },
});
```

Vite's docs warn about the opposite case too: "There are cases when other servers might respond instead of Vite." If another server listens on `127.0.0.1:5173` while Vite listens on `::1`, the two addresses show two different apps. When `localhost` resolves to a different address than the browser would use, Vite prints the address it really listens on.

## Network: use --host to expose, and what --host does

`Network: use --host to expose` is a hint, not an error. Vite listens on `localhost` by default, so only programs on your own computer can connect. A comment in Vite's source calls `localhost` "a secure default". There is no network address to print, so Vite tells you how to get one. The hint disappears once you set a host.

`--host` makes Vite listen on every address of your computer. Vite's docs describe `host: true` as listening "on all addresses, including LAN and public addresses."

```bash
npm run dev -- --host
```

Vite then prints a `Network:` line for each network interface:

```text
  ➜  Local:   http://localhost:5173/
  ➜  Network: http://192.168.1.23:5173/
```

Any device on the same Wi-Fi can open the `Network:` URL. To make it permanent, set `server.host: true` in `vite.config.js`.

### The risk of --host on a shared network

`--host` opens your dev server to everyone on the network you're on, not only to your phone. On a café, coworking, hotel or conference Wi-Fi, that includes strangers. They can load your app and the source files Vite serves to the browser.

The host check doesn't protect you here. Vite allows all IP addresses by default, so a request to `http://192.168.1.23:5173` passes it.

Vite's own security advisories show what else is at stake. Vite's `server.fs.deny` option keeps files the dev server shouldn't serve out of reach. In March 2025, Vite published two high-severity advisories, [CVE-2025-30208](https://github.com/vitejs/vite/security/advisories/GHSA-x574-m823-4x7w) and [CVE-2025-31125](https://github.com/vitejs/vite/security/advisories/GHSA-4r4m-qw57-chr8), in which a crafted URL got past that check. Both say: "Only apps explicitly exposing the Vite dev server to the network (using `--host` or `server.host` config option) are affected." Vite has published more `server.fs.deny` fixes since, the latest in October 2026.

Keep these rules:

- Use `--host` on networks you trust, such as your home Wi-Fi.
- Pass `--host` for the session instead of committing `host: true` to `vite.config.js`, so it isn't on every time anyone on your team starts the project.
- Keep Vite up to date.

An alternative is to leave Vite on `localhost` and let Expose share it on the network, with a password if you need one. See [your phone or another computer](#open-localhost5173-on-your-phone-or-another-computer).

## Blocked request. This host is not allowed

Vite shows this when a request arrives for a hostname it doesn't know:

```text
Blocked request. This host ("abc123.sharedwithexpose.com") is not allowed.
To allow this host, add "abc123.sharedwithexpose.com" to `server.allowedHosts` in vite.config.js.
```

The check arrived on January 20, 2025, in Vite 6.0.9, 5.4.12 and 4.5.6, with the security advisory [GHSA-vg6x-rcgg-rjx6](https://github.com/vitejs/vite/security/advisories/GHSA-vg6x-rcgg-rjx6). It stops DNS rebinding, where a malicious website points its own hostname at your machine and reads your dev server. Projects that worked through a tunnel or a custom hostname before that upgrade started showing the error after it.

`localhost`, names under `.localhost` and all IP addresses are allowed by default. That's why `http://192.168.1.23:5173` works while a tunnel URL or a custom local domain doesn't. The fix is one line: add the domain to `server.allowedHosts`.

```js
export default defineConfig({
  server: {
    allowedHosts: ['.sharedwithexpose.com'],
  },
});
```

Don't set `allowedHosts: true`. Vite's docs say it "allows any website to send requests to your dev server through DNS rebinding attacks". The [Vite guide](https://expose.dev/docs/guides/vite) covers the setting for Expose URLs, and [Invalid Host header: the fix for each framework](https://expose.dev/blog/invalid-host-header) covers the same check in webpack, Angular, Next.js, Django and Rails.

## Laravel: your app is not on port 5173

In a Laravel project, Vite on port 5173 only serves your CSS and JavaScript and the hot reloading connection. The app itself runs elsewhere: at a Herd or Valet site such as `http://my-app.test`, or at `http://localhost:8000` with `php artisan serve`. Laravel's `@vite` directive puts links to the Vite server into each page.

If you open `localhost:5173` in a Laravel project, you'll usually see a page titled "Laravel Vite" that says: "This is the Vite development server that provides Hot Module Replacement for your Laravel application." It also shows your `APP_URL`. Open that URL instead.

If you secured the site in Herd, the Laravel Vite plugin uses Herd's certificate. Vite then serves over HTTPS on your site's hostname, such as `https://my-app.test:5173`.

To share a Laravel app, share the site, not port 5173:

```bash
expose share my-app.test
```

If `npm run dev` is running, Expose detects the Vite process, shares it too and rewrites the page, so CSS, JavaScript and hot reloading work through the tunnel without a change to `vite.config.js`. The [Laravel, Herd and Vite section](https://expose.dev/docs/guides/vite#3-laravel-herd-and-vite) of the Vite guide has the details. Herd includes Expose and can share from its own UI or with `herd share`. See [Expose with Laravel Herd](https://expose.dev/docs/integrations/laravel-herd).

## Open localhost:5173 on your phone or another computer

`localhost` always means the device you type it on. On your phone, `localhost:5173` is the phone itself. Another device needs your computer's address or a public URL:

| Who opens it | Command | The URL they open |
|---|---|---|
| Your phone or a laptop on the same Wi-Fi | `expose share http://localhost:5173 --lan --qr-code` | `http://192.168.1.23:8080`, scanned from the QR code |
| The same, with Vite alone | `npm run dev -- --host` | `http://192.168.1.23:5173` |
| A client, a tester, a webhook provider, any network | `expose share http://localhost:5173` | A public HTTPS URL such as `https://abc123.sharedwithexpose.com` |

### On the same Wi-Fi: --lan with a QR code

```bash
expose share http://localhost:5173 --lan --qr-code
```

Expose prints a LAN URL and a QR code in the terminal. Scan it with your phone's camera and the app opens. Vite stays on `localhost`, so you don't need `--host`. The LAN URL is an IP address, which Vite's host check allows, so `allowedHosts` doesn't need a change either.

Details from the [local network sharing docs](https://expose.dev/docs/client/lan-sharing):

- Your computer serves the share itself. You don't need an Expose account or an internet connection.
- Expose listens on port 8080, or on another free port when 8080 is taken. `--lan=9000` picks the port.
- Add `--basicAuth="user:password"` on a network you don't trust. The share ends when you stop Expose.
- The [request dashboard](https://expose.dev/docs/client/dashboard) at `http://127.0.0.1:4040` lists every request the phone makes.
- It needs the native Expose client, version 4.2 or later. Install it with `curl -fsSL https://expose.dev/install.sh | sh` on macOS and Linux, or with `irm https://expose.dev/install.ps1 | iex` on Windows.

A LAN share is plain HTTP. Browsers only allow some features, such as the camera, the clipboard and service workers, on HTTPS pages or on `localhost`. If you test those on a phone, use a public HTTPS URL instead. If the phone can't connect at all, check that both devices are on the same network and that your computer's firewall allows incoming connections for `expose`.

### Anywhere: a public HTTPS URL

```bash
expose share http://localhost:5173
```

Expose gives the dev server a public HTTPS URL that opens on any device and any network, including mobile data. It also works for webhooks and OAuth callbacks that need to reach your machine. Visitors don't see a warning page first, on any plan.

Vite blocks the new hostname until you allow it, so add `.sharedwithexpose.com` to `server.allowedHosts` as shown [above](#blocked-request-this-host-is-not-allowed). The free plan gives you a random URL on every connection. With [Expose Pro](https://expose.dev/#pricing), at $79 per user per year, you can reserve a subdomain and get the same URL every time. The [Vite guide](https://expose.dev/docs/guides/vite) walks through both.

## Questions

### What is localhost:5174?

It's Vite's dev server after it found port 5173 taken. A second Vite server goes to 5174, a third to 5175, and so on. If you expected 5173, another Vite server is still running. Stop it, or set `strictPort: true`.

### Can people on the internet open my localhost:5173?

Not with Vite's default settings. `localhost` only answers on your own computer. With `--host`, Vite listens on every address, which its docs say includes "LAN and public addresses". On a laptop behind a home router, that means your local network, because the router doesn't pass connections from the internet unless you set up port forwarding. On a cloud server, or a machine with a public IPv6 address and no firewall, it means the internet. To share the dev server on purpose, use a tunnel such as `expose share http://localhost:5173`.

### How do I open localhost:5173 automatically when Vite starts?

Pass `--open`, or set `server.open: true` in `vite.config.js`. Vite then opens the app in your browser on start. Set the `BROWSER` environment variable, for example to `firefox`, to choose the browser.

### Is port 5173 only used by Vite?

On a developer machine it's almost always a Vite dev server, from your own project or from a framework built on Vite. Run `lsof -i :5173` on macOS or Linux, or `netstat -ano | findstr :5173` on Windows, to see which process holds it.

---

Vite behaviour is described as documented on December 6, 2026, for Vite 8.4: [server options](https://vite.dev/config/server-options), [preview options](https://vite.dev/config/preview-options), the [CLI reference](https://vite.dev/guide/cli), [troubleshooting](https://vite.dev/guide/troubleshooting), the [Vite 3 announcement](https://vite.dev/blog/announcing-vite3) and [migration guide](https://v3.vite.dev/guide/migration.html), the [Vite source](https://github.com/vitejs/vite/tree/main/packages/vite/src/node) on GitHub, the [security advisories](https://github.com/vitejs/vite/security/advisories) GHSA-vg6x-rcgg-rjx6, GHSA-x574-m823-4x7w and GHSA-4r4m-qw57-chr8, and the [Laravel Vite plugin](https://github.com/laravel/vite-plugin).
