Next.js dev server default port: 3000

Next.js dev server uses TCP port 3000 by default. next dev moves to the next free port, but only if you did not choose one. With no -p, --port or PORT it tries 3001, 3002 and so on (up to ten more ports) and prints a warning that names the process holding 3000.

Updated

Key facts

Default ports for Next.js dev server
PortProtocolRoleCategory
3000TCPnext dev and next startFrontend

What happens when the port is busy

next dev moves to the next free port, but only if you did not choose one. With no -p, --port or PORT it tries 3001, 3002 and so on (up to ten more ports) and prints a warning that names the process holding 3000. Set a port by any of those three routes and a busy port is an error: Next.js reports EADDRINUSE and exits. next start never moves. Separately, since Next.js 16 a second next dev in the same project directory is refused, because .next/dev/lock is already held.

Change the port

CLI flag
next dev -p 3001

--port is the long form of -p. Pick a number that no other project on the machine uses. A port set this way also turns off the automatic move to a free port.

PORT in the shell
PORT=3001 next dev

Set it inline or export it. A PORT line in .env is ignored, because the HTTP server starts before any other code is initialised. A port set this way also turns off the automatic move to a free port.

package.json script
{
  "scripts": {
    "dev": "next dev -p 3001"
  }
}

Pins the port for everyone who runs npm run dev. Give each project you run side by side a different number.

Loopback only
next dev -p 3001 -H 127.0.0.1

-H, --hostname sets the address next dev listens on. The default is 0.0.0.0, which other devices on your network can reach.

Environment variable: PORT. Read when you start the server from the shell. It cannot be set in .env, because the HTTP server boots before any other code is initialised. An exported PORT also stops next dev moving to a free port. -p and --port are the documented alternative.

Bind address

next dev listens on 0.0.0.0 by default (the -H, --hostname default), so other devices on your network can reach it. Pass -H 127.0.0.1 to keep it on the loopback interface. If you do expose it, Next.js blocks cross-origin requests to dev-only assets and endpoints by default, so you may need the allowedDevOrigins option.

What else uses this port

TCP port 3000 is also the default for Nuxt dev server and Rails server.

The dataset is the 12 tools on the ports index.

Find and free this port

These commands find the process that holds TCP port 3000 and stop it. They come from the Port in use command generator. PID_NUMBER stands for the process ID you read from the first command: replace it before you run the others.

macOS (zsh)
lsof -nP -iTCP:3000 -sTCP:LISTEN
ps -p PID_NUMBER -o pid,ppid,user,command
kill -TERM PID_NUMBER
Linux (bash)
ss -ltnp 'sport = :3000'
ps -p PID_NUMBER -o pid,ppid,user,command
kill -TERM PID_NUMBER
Windows (PowerShell)
Get-NetTCPConnection -LocalPort 3000 -State Listen -ErrorAction SilentlyContinue | Select-Object LocalAddress, LocalPort, State, OwningProcess
Get-CimInstance -ClassName Win32_Process -Filter "ProcessId = PID_NUMBER" | Select-Object ProcessId, ParentProcessId, Name, CommandLine
Stop-Process -Id PID_NUMBER

Read the output of the second command before you stop anything, because the owner may be a container or another person’s process. Then run the first command again to confirm the port is free.

Next free ports

Counting up from 3000, the next three ports that no tool in this dataset uses as a default are 3001, 3002, and 3003. They are suggestions only: another program on your machine may hold any of them, so run the find command above before you choose one.

In Rig

Rig starts Next.js with -p N, where N is the project’s port. If something else holds N, start_project returns a portConflict that names the owner and a suggested free port, unless you pass resolve_port=kill (stop the owner) or resolve_port=suggest (switch the project to a free port).

Collisions in practice

3000 is the default for next dev and next start, and Nuxt’s devServer.port defaults to it too, so a workspace holding a Next app and a Nuxt app collides on the first start. next dev moves to 3001 quietly when nobody chose a port, which is how a stale tab on 3000 ends up showing a different app. The sharper trap is PORT: a value in your shell is honoured, a PORT line in .env is not, and an exported PORT pins every Next project in that shell to one number, so the second one fails with EADDRINUSE. Put the port in the dev script with -p.

Frequently asked questions

Why did Next.js start on port 3001?

Port 3000 was busy and you had not chosen a port. With no -p, --port or PORT, next dev tries the following ports in turn, up to ten, and warns that port 3000 is in use by a named process and which port it used instead. Pass -p 3000 and a clash becomes an error instead.

Can I set the Next.js port in .env?

No. Next.js does not read PORT from .env, because the HTTP server starts before any other code is initialised. Use next dev -p 3001, an inline PORT=3001 next dev, or put the flag in the dev script in package.json.

What does “Another next dev server is already running” mean?

Since Next.js 16, next dev holds a lock file at .next/dev/lock, so a second next dev in the same project directory is refused. From 16.2 the lock records the server’s PID, port and URL, and the error lists the existing server’s URL, PID, project directory and log path. It then offers two options: use the server that is already running, or run kill with the PID shown to stop it and start a new one.

Is next dev reachable from other devices on my network?

By default, yes. The hostname default for next dev is 0.0.0.0. Pass -H 127.0.0.1 to listen on the loopback interface only. If you use a network address, you may also need allowedDevOrigins in the Next.js config, because cross-origin requests to dev-only assets are blocked by default.

Sources

  1. Next.js: next CLI reference (port, -p, PORT, hostname)Official documentation, checked 13 October 2026
  2. Next.js 16.2: AI improvements (dev server lock file)Official documentation, checked 13 October 2026
  3. Next.js: allowedDevOriginsOfficial documentation, checked 13 October 2026
  4. Next.js: published CLI source (next@16.4.0 on npm)Editorial, checked 13 October 2026

Busy ports in Rig

When a start fails because a port is taken, Rig shows which process owns it when it can, and lets you reclaim the port or choose another. You do not need Rig to use this page.

Related

https://userig.app/ports/nextjs