# localhost:3000: what runs there, why it won't load, and how to open it on your phone or share it

December 4, 2026, The Expose team

`localhost:3000` is your own computer, on TCP port 3000. `localhost` is the loopback address, `127.0.0.1` in IPv4 or `::1` in IPv6, and 3000 is the port your development server listens on.

Next.js, Rails, Nuxt, Create React App and the Express "Hello world" example all start on port 3000 unless you tell them otherwise. So `http://localhost:3000` only loads while one of them runs on your machine, and only on your machine. On a phone or a colleague's laptop, `localhost` is that device.

Find what you see, then jump to the fix:

| What you see | What it means | Fix |
|---|---|---|
| "localhost refused to connect", `ERR_CONNECTION_REFUSED` | Nothing accepts connections on port 3000 at the address the browser tried | [Refused connection](#fix-localhost-refused-to-connect-err-connection-refused) |
| `Error: listen EADDRINUSE: address already in use :::3000` | Another process already holds port 3000 | [Free port 3000](#fix-eaddrinuse-port-3000-is-already-in-use) |
| The app opens on `localhost:3001` or `localhost:3002` | Next.js moved up a port because 3000 was taken | [Why 3001](#why-nextjs-starts-on-localhost3001-or-3002) |
| `connect ECONNREFUSED ::1:3000` | The client tried the IPv6 address and the server listens on IPv4 only | [IPv6 and IPv4](#the-server-listens-on-ipv6-only-or-ipv4-only) |
| `ERR_SSL_PROTOCOL_ERROR` on `https://localhost:3000` | The dev server speaks plain HTTP | [Use http://](#the-url-starts-with-https) |
| It works on your laptop but not on your phone | `localhost` on the phone means the phone | [Open it on your phone](#open-localhost3000-on-your-phone) |

## What runs on port 3000

These tools use port 3000 by default. The last column is how you move one of them to another port, here 4000:

| Tool | What starts it on 3000 | Use another port |
|---|---|---|
| Next.js | `npm run dev` (`next dev`) and `next start` | `next dev -p 4000`, or the `PORT` variable |
| Ruby on Rails | `bin/rails server` | `bin/rails server -p 4000` |
| Nuxt | `npm run dev` (`nuxt dev`) | `nuxt dev --port 4000`, or `NUXT_PORT`, `NITRO_PORT` or `PORT` |
| Express | The "Hello world" example, with `const port = 3000` | Change that line |
| Create React App | `npm start` | The `PORT` variable |
| Grafana | The Grafana server, out of the box | `http_port` in the `[server]` section of the config file, or `GF_SERVER_HTTP_PORT` |
| Gitea | The Gitea web server | `HTTP_PORT` in the `[server]` section of `app.ini` |

Vite doesn't use 3000. Its dev server listens on [port 5173](https://expose.dev/blog/localhost-5173), and moves to the next free port when 5173 is taken. Tomcat, Jenkins and Spring Boot start on [port 8080](https://expose.dev/blog/localhost-8080). Create React App is deprecated, but many older projects still start with it.

Flags pass through npm after `--`, and that works the same on every operating system:

```bash
npm run dev -- -p 4000
```

A variable such as `PORT` is set differently in each shell:

```bash
# macOS and Linux
PORT=4000 npm start
```

```powershell
# Windows PowerShell
$env:PORT=4000; npm start
```

```bat
:: Windows Command Prompt
set PORT=4000
npm start
```

In Command Prompt, keep `set` on its own line. `set PORT=4000 && npm start` stores the space before `&&` in the value. Next.js also can't read `PORT` from a `.env` file. [Its CLI docs](https://nextjs.org/docs/app/api-reference/cli/next) explain that the HTTP server starts before any other code runs.

We checked each default on December 4, 2026, in the docs for [Next.js](https://nextjs.org/docs/app/api-reference/cli/next), [Rails](https://guides.rubyonrails.org/command_line.html), [Nuxt](https://nuxt.com/docs/4.x/api/commands/dev), [Express](https://expressjs.com/en/starter/hello-world.html), [Create React App](https://create-react-app.dev/docs/advanced-configuration/), [Grafana](https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/), [Gitea](https://docs.gitea.com/administration/config-cheat-sheet) and [Vite](https://vite.dev/config/server-options).

## Fix localhost refused to connect (ERR_CONNECTION_REFUSED)

Chrome shows "This site can't be reached. localhost refused to connect." with the code `ERR_CONNECTION_REFUSED`. The request reached your computer, and no program accepted it on port 3000. There are four usual causes.

### The dev server isn't running

Look at the terminal where you started it. If the server crashed, the error is printed above the prompt. Start it again and wait for the line with the URL.

To check from a second terminal whether anything listens on port 3000:

```bash
# macOS and Linux
lsof -nP -iTCP:3000 -sTCP:LISTEN
```

```bat
:: Windows
netstat -ano | findstr :3000
```

No output means nothing listens on port 3000. On Windows, look for a line that ends in `LISTENING`.

### It runs on a different port

Open the URL your dev server prints, not the one you remember. Next.js moves to 3001 when 3000 is taken, as [explained below](#why-nextjs-starts-on-localhost3001-or-3002). Vite prints 5173. A `PORT` variable left in your shell, or a `-p` flag in the `dev` script of `package.json`, also changes the port.

### It runs in Docker without a published port

A server inside a container listens on the container's own network. Your browser can reach it only when you publish the port:

```bash
docker run -p 3000:3000 my-app
```

`-p 3000:3000` maps port 3000 on your computer to port 3000 in the container. In Docker Compose, the same mapping goes under `ports:` as `"3000:3000"`.

The server inside the container also has to listen on `0.0.0.0`. A server on `127.0.0.1` accepts connections from inside the container only, so the published port leads nowhere. The official [Next.js Docker example](https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile) sets `ENV HOSTNAME="0.0.0.0"`. For Rails, start the server with `bin/rails server -b 0.0.0.0`.

### The server listens on IPv6 only, or IPv4 only

`localhost` has two addresses, `127.0.0.1` and `::1`. A server can listen on one of them and not the other. A client that connects to the other address gets a refused connection, even though the server runs. The error `connect ECONNREFUSED ::1:3000` means the client tried `::1`.

Node.js made this more common. Since Node.js 17, `dns.lookup()` returns addresses in the order the system gives them, instead of putting IPv4 first. The [Node.js DNS docs](https://nodejs.org/api/dns.html) list the change in version 17.0.0. If your system lists `::1` first, a Node.js server told to listen on `localhost` can end up on `::1` only, and a Node.js client asking for `localhost` can try `::1` first.

See which address the server listens on:

```bash
lsof -nP -iTCP:3000 -sTCP:LISTEN
```

The `NAME` column shows `127.0.0.1:3000` for IPv4 only, `[::1]:3000` for IPv6 only, and `*:3000` for every address. Then pick one fix:

- Connect to the address the server uses: `http://127.0.0.1:3000` or `http://[::1]:3000`.
- In your own Node.js server, call `listen(3000)` without a host. The [Node.js net docs](https://nodejs.org/api/net.html) say it then listens on `::`, which on most operating systems accepts IPv4 connections too.
- Start Node.js with `--dns-result-order=ipv4first` to put IPv4 first again.

Rails avoids the problem. Its sample startup output in the [Rails guide](https://guides.rubyonrails.org/command_line.html) lists both `http://127.0.0.1:3000` and `http://[::1]:3000`.

### The URL starts with https

Dev servers on port 3000 speak plain HTTP unless you set up a certificate. `https://localhost:3000` starts a TLS handshake that the server doesn't understand, and Chrome shows `ERR_SSL_PROTOCOL_ERROR` instead of refusing. Type `http://localhost:3000`.

## Fix EADDRINUSE: port 3000 is already in use

Node.js prints this when it can't listen on port 3000 because another process already does:

```
Error: listen EADDRINUSE: address already in use :::3000
```

`:::3000` is `::`, every address, followed by the port. The other process is usually an old dev server: a terminal tab you forgot, a run that crashed and left a child process behind, or a different project. Find it, then stop it.

### macOS and Linux

```bash
lsof -i :3000
```

The `PID` column has the process ID. Stop that process:

```bash
kill 48213
```

If it's still listed a few seconds later, force it with `kill -9 48213`.

`lsof -i :3000` also lists programs connected to port 3000, such as your browser. Stop only the process on the line that ends in `(LISTEN)`. This command finds the listening process and stops it in one step:

```bash
kill $(lsof -t -iTCP:3000 -sTCP:LISTEN)
```

If `lsof` prints nothing but the port is still taken, run it with `sudo`. The process may belong to another user. On Linux without `lsof`, `ss -ltnp | grep :3000` shows the process name and PID.

If the process is Docker's, stop the container instead. `docker ps` shows which container publishes port 3000, and `docker stop` with its name frees the port.

### Windows

In Command Prompt or PowerShell:

```bat
netstat -ano | findstr :3000
```

`-a` lists listening ports, `-n` shows numbers instead of names, and `-o` adds the process ID, which is the last column. Take the PID from the line that says `LISTENING` and stop it:

```bat
taskkill /PID 48213 /F
```

`/F` ends the process by force. PowerShell has its own commands for the same two steps:

```powershell
Get-NetTCPConnection -LocalPort 3000 -State Listen | Select-Object OwningProcess
Stop-Process -Id 48213
```

### Any operating system: npx kill-port

```bash
npx kill-port 3000
npx kill-port 3000 3001 3002
```

[kill-port](https://github.com/tiaanduplessis/kill-port) is an npm package, not part of Node.js, so `npx` downloads it the first time. It sends `SIGKILL` by default, so the server gets no chance to shut down cleanly. On macOS and Linux it needs `lsof` installed.

## Why Next.js starts on localhost:3001 or 3002

When port 3000 is taken and you didn't choose a port, `next dev` moves to the next one and prints a warning:

```
Port 3000 is in use by process 48213, using available port 3001 instead.
```

The [Next.js source](https://github.com/vercel/next.js/blob/canary/packages/next/src/server/lib/start-server.ts) tries up to 10 ports, 3001 to 3010. It does this only in development, and only when neither `--port` nor `PORT` is set. With a port you set yourself, Next.js prints "Failed to start server" and exits with the EADDRINUSE error.

So `localhost:3001` usually means an older dev server still holds 3000, and `localhost:3002` means two of them. That causes three problems:

- `localhost:3000` still shows the old server, which may be another project or yesterday's code.
- OAuth callback URLs, webhook endpoints and variables such as `NEXTAUTH_URL` that say `localhost:3000` now reach the wrong app.
- A tunnel started with `expose share http://localhost:3000` shares the old server too.

Stop the old process with the commands above and start `npm run dev` again, so the app is back on 3000. To make Next.js fail instead of moving, pin the port with `npm run dev -- -p 3000`.

Create React App asks before it moves to another port. Some projects use 3001 on purpose, for an API that runs next to a frontend on 3000. If yours does, its `package.json` or README says so.

## Open localhost:3000 on your phone

`localhost` on your phone is the phone. To open your dev server there, the phone needs an address it can reach: your computer's address on the Wi-Fi, or a public URL.

### On the same Wi-Fi, with Expose

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

Expose serves the app on your computer's network address and prints that LAN URL, followed by a QR code:

```
Shared site              http://localhost:3000
Dashboard                http://127.0.0.1:4040
LAN URL                  http://192.168.1.23:8080
```

Scan the code with the phone's camera. Nothing goes through an Expose server, so you need no account and no internet connection. Your dev server keeps listening on `localhost`, and you change nothing in its config.

Expose uses port 8080, or any free port if 8080 is taken. `--lan=9000` picks the port yourself. The phone's requests show up in the dashboard at `http://127.0.0.1:4040`, where you can replay them. If the phone can't connect, allow incoming connections for `expose` in your computer's firewall. LAN sharing needs Expose 4.2 or later. The [local network sharing docs](https://expose.dev/docs/client/lan-sharing) cover the details.

To install Expose on macOS or Linux:

```bash
curl -fsSL https://expose.dev/install.sh | sh
```

On Windows, in PowerShell:

```powershell
irm https://expose.dev/install.ps1 | iex
```

With Homebrew, run `brew install --cask expose`.

### On the same Wi-Fi, by binding the server to 0.0.0.0

The other way is to make the dev server itself listen on your network, and to open `http://YOUR-IP:3000` on the phone. Some tools already do this:

| Tool | Listen on your network |
|---|---|
| Next.js | Already does. `next dev` listens on `0.0.0.0` by default |
| Create React App | Already does. It binds to every address on the computer by default |
| Express | `app.listen(3000)` without a host listens on every address |
| Rails | `bin/rails server -b 0.0.0.0` |
| Nuxt | `nuxt dev --host 0.0.0.0` |
| Vite | `npm run dev -- --host` |

Then find your computer's address on the network:

```bash
# macOS, Wi-Fi
ipconfig getifaddr en0

# Linux
hostname -I
```

On Windows, run `ipconfig` and use the `IPv4 Address` line. Open that address with the port on the phone, for example `http://192.168.1.23:3000`. Your firewall has to allow incoming connections for Node.js or Ruby.

Rails accepts requests for any IP address in development by default, according to the [Rails configuration guide](https://guides.rubyonrails.org/configuring.html), so you don't need to change `config.hosts`. Next.js serves its development resources only to `localhost`, its subdomains and the hostname it was started with. If the page loads on the phone but doesn't update when you save, add the computer's address to `allowedDevOrigins` in `next.config.js`. This applies to both ways of sharing on the Wi-Fi:

```js
module.exports = {
  allowedDevOrigins: ['192.168.1.23'],
}
```

### Which one to use

| | `expose share --lan` | Bind to 0.0.0.0 |
|---|---|---|
| Dev server config | No change | A flag or setting per tool |
| Address on the phone | Scan the QR code | Look up your IP and type it |
| Who can open it | Everyone on the network, while `expose` runs | Everyone on the network, whenever the dev server runs, on every network you join |
| Password | `--basicAuth="user:secret"` | Only what your app has |
| Request log and replay | The dashboard at `127.0.0.1:4040` | None |
| HTTPS | No | No |

If you use Next.js or Create React App, typing the IP address works without installing anything. That also means the dev server can be opened from every device on the network you are on, including café Wi-Fi.

Neither way gives you HTTPS. Phone browsers only allow the camera, the clipboard and service workers on HTTPS pages, so test those through a public URL.

## Share localhost:3000 with someone elsewhere

When the other person isn't on your Wi-Fi, or the page needs HTTPS, give the app a public URL:

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

The first time, Expose opens your browser so you can sign in or create a free account. Then it prints a public HTTPS URL that works on any network, including a phone on mobile data. The dashboard at `http://127.0.0.1:4040` shows a QR code for that URL. Visitors see your app directly, with no warning page in front of it, on any plan.

The free plan gives you a random URL on each connection and a time limit per connection. With [Expose Pro](https://expose.dev/#pricing), at $79 per user per year, add `--subdomain=my-app` for a URL that stays the same, which matters for webhook endpoints and OAuth callbacks.

Check two framework settings before you send the link:

- **Next.js** blocks hot reloading for hostnames it doesn't know. Add `'**.sharedwithexpose.com'` to `allowedDevOrigins`. The [Next.js guide](https://expose.dev/docs/guides/nextjs) explains why it needs two asterisks.
- **Vite, webpack, Angular, Django and Rails** answer an unknown hostname with "Invalid Host header" or a blocked request. [The Invalid Host header fix for each framework](https://expose.dev/blog/invalid-host-header) has the setting for each one.

Anyone with the URL can open it, so put a password in front with `--basicAuth="user:secret"`. The URL works only while `expose` runs on your computer. If the app has to stay online when your laptop is closed, deploy it instead. [Hosting from localhost](https://expose.dev/blog/hosting-localhost) compares a tunnel, port forwarding and a deploy.

## Questions

### Is localhost:3000 a website?

No. `localhost:3000` is an address on your own computer, and nobody else can open it. If someone sends you a `localhost:3000` link, it points at your computer, not theirs, so it only works if you run the same app.

### Can I open localhost:3000 from another computer?

Not with the name `localhost`, because on the other computer it means that computer. On the same network, use your computer's IP address with the port, or `expose share http://localhost:3000 --lan`. From anywhere else, use a public URL from `expose share http://localhost:3000`.

### Is port 3000 open to the internet?

No. A server on port 3000 can't be reached from the internet unless you forward the port on your router or use a tunnel. A server that listens on `0.0.0.0`, as `next dev` does by default, can be opened by other devices on the same network if your firewall lets them in.

### Why does localhost:3000 show a different project?

An old dev server probably still holds port 3000. Find it with `lsof -i :3000` or `netstat -ano | findstr :3000` and stop it. If the port is free and the old app still appears, a service worker from that app may be serving cached pages. Browsers keep service workers per origin, and `localhost:3000` is the same origin for every project you run there. In Chrome, open DevTools, go to Application, then Service workers, and click Unregister.
