Fix Next.js "Port 3000 is Already in Use"

Your Next.js dev server cannot start because another process is using port 3000. Here is how to fix it.

Updated April 20264 min read

The error

Running npm run dev or next dev shows:

- error Port 3000 is already in use.
Use `next dev --port <port>` to use a different port.

Next.js 13+ auto-detects port conflicts and shows this message. Older versions may show the raw EADDRINUSE error.

Fix 1: portrm (instant)

$ ptrm fix 3000
  Port 3000 in use
  node (PID 67890) - next-server
  Killed PID 67890. Port 3000 is free.

$ npm run dev  # starts on port 3000

Fix 2: Kill manually

# macOS
$ lsof -ti :3000 | xargs kill -9

# Linux
$ fuser -k 3000/tcp

# Windows
> netstat -ano | findstr :3000
> taskkill /PID <PID> /F

Fix 3: Use a different port

Next.js supports port selection via CLI flag or environment variable:

# CLI flag
$ next dev --port 3001
$ next dev -p 3001

# Environment variable
$ PORT=3001 npm run dev

# .env.local
PORT=3001

Fix 4: Update package.json

// package.json
{
  "scripts": {
    "dev": "next dev -p 3001",
    "predev": "ptrm fix 3001"
  }
}

Common causes

CauseWhat to do
Old next-server processptrm fix 3000
Turbopack HMR zombieKill orphaned turbopack process: ptrm scan | grep turbo
React app on same portUse different port for one project
API route /api running separatelyNext.js API routes share the same port
Docker dev containerCheck Docker port mappings: docker ps

Next.js with Turbopack

When running next dev --turbo, Turbopack uses the same port as the dev server. If a Turbopack process crashes, it may leave the port occupied:

$ ptrm 3000
  Port 3000
  PID    73201
  Name   next-server (turbopack)

$ ptrm fix 3000  # kills the zombie turbopack process

Running multiple Next.js projects

If you work on multiple Next.js projects simultaneously, assign a unique port to each:

# Project A: .env.local
PORT=3000

# Project B: .env.local
PORT=3001

# Project C: .env.local
PORT=3002

Auto-clear ports before next dev

Add portrm to your dev workflow. One command, zero port conflicts.