Skip to content

Dev servers

Port 3000 is already in use? Free it in one line.

Something else is still listening on the port your dev server wants: usually an old copy of the same server, left running in another tab. Find it, stop it, and start again. The commands for macOS, Linux and Windows are below.

What it looks like
  • NodeError: listen EADDRINUSE: address already in use :::3000
  • RailsAddress already in use - bind(2) for "127.0.0.1" port 3000 (Errno::EADDRINUSE)
  • DjangoError: That port is already in use.
  • Next.js⚠ Port 3000 is in use, trying 3001 instead.
The fix

Find what holds the port, then stop it

Read what the first command prints before you stop anything: it might be a database or another app you want to keep.

macOS and Linux

  1. 1. See what holds the port, and its PID

    lsof -nP -iTCP:3000 -sTCP:LISTEN
  2. 2. Ask it to stop

    kill $(lsof -t -iTCP:3000 -sTCP:LISTEN)
  3. 3. Still there? Force it

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

Swap 3000 for your port. A process you started yourself needs no sudo.

Linux without lsof

  1. 1. See what holds the port

    ss -ltnp 'sport = :3000'
  2. 2. Stop it

    fuser -k 3000/tcp

ss ships with most distributions, fuser with psmisc.

Windows (PowerShell)

  1. 1. See which process holds the port

    Get-NetTCPConnection -LocalPort 3000 -State Listen | Select-Object OwningProcess
  2. 2. Stop it

    Stop-Process -Id (Get-NetTCPConnection -LocalPort 3000 -State Listen).OwningProcess

In Command Prompt: netstat -ano | findstr :3000, then taskkill /PID <pid> /F.

Why

Why the port is taken

  • The same server, still running

    You started it in a terminal tab you forgot, or closed the window and the process lived on. It's the most common case.

  • A crash that left a child behind

    A watcher or bundler crashed, but a worker it started kept the port open.

  • Two projects with the same default

    Next.js, Rails and Express all start on 3000, Vite on 5173 and Django on 8000, so two projects collide as soon as both run.

  • A container mapping the port

    A Docker Compose service publishes the same port on your machine. docker ps shows it in the PORTS column.

  • macOS AirPlay Receiver

    On recent macOS it listens on ports 5000 and 7000, the defaults for Flask and some others. Turn it off under System Settings → General → AirDrop & Handoff.

Stop chasing it

Let the app that starts your servers check the ports

lpm, a free desktop app, starts each project's dev servers with one click. Before it starts one, it checks the service's port.

It names what holds the port

Another lpm project, or a process and its PID, and it can stop that and start yours in one click.

You choose what happens, per service

ask, the default, asks before freeing the port. free frees it without asking, and fail refuses to start.

web: { cmd: npm run dev, port: 3000, portConflict: free }

Every listening port, and who holds it

The lpm command lists each listening TCP port with the project and service behind it.

lpm ports

lpm checks ports. It doesn’t assign or isolate them.

From 0:39 in the three-minute tour: free a busy port in one click.

FAQ

Ports in use: what people ask

  • How do I find what's using port 3000?
    On macOS or Linux, run lsof -nP -iTCP:3000 -sTCP:LISTEN: it prints the command and its PID. On Linux without lsof, ss -ltnp 'sport = :3000' does the same. On Windows, run Get-NetTCPConnection -LocalPort 3000 -State Listen in PowerShell, or netstat -ano | findstr :3000 in Command Prompt, and look up the PID in Task Manager.
  • How do I kill the process on port 3000 on a Mac?
    Run kill $(lsof -t -iTCP:3000 -sTCP:LISTEN). If it's still listening a few seconds later, use kill -9 with the same PID. Check what it is first, so you don't stop a database you need.
  • How do I free a port on Windows?
    In PowerShell: Stop-Process -Id (Get-NetTCPConnection -LocalPort 3000 -State Listen).OwningProcess. In Command Prompt: find the PID with netstat -ano | findstr :3000, then run taskkill /PID <pid> /F.
  • What does EADDRINUSE mean?
    It's the operating system's error for an address already in use: your server asked to listen on a port that another process is listening on. Only one process can listen on a port and address at a time.
  • Why is port 5000 in use on my Mac?
    On recent macOS, AirPlay Receiver listens on ports 5000 and 7000. Turn it off under System Settings → General → AirDrop & Handoff, or run your server on another port.
  • Can I just use another port?
    Yes, and some tools do it for you: Next.js and Vite move to the next free port. But the old server is still running, and the URL you have open may be talking to it instead of your new code.
  • Can lpm free the port for me?
    Yes. lpm checks each service's port before it starts it, names what holds it, and frees it with one click. Set portConflict: free to free it without asking, or fail to refuse to start. lpm is free and open source for macOS, Windows and Linux.