Guides

"Port 3000 is already in use" on Mac: find and stop what's using it

Updated · 2 min read

You start your dev server and it fails with EADDRINUSE, address already in use, or port 3000 is already in use. Something is still listening on that port, usually an earlier copy of the same server that never stopped: a closed Terminal tab, a crashed editor, a watcher left running.

The short answer: find it, then stop it.

lsof -nP -iTCP:3000 -sTCP:LISTEN
kill <PID>

1. Find what's using the port

lsof -nP -iTCP:3000 -sTCP:LISTEN

Change 3000 to your port. You'll see something like:

COMMAND   PID  USER   FD   TYPE  DEVICE  SIZE/OFF NODE NAME
node     4821  you    23u  IPv6  0x…     0t0      TCP *:3000 (LISTEN)

COMMAND is the program and PID is its process ID. What the flags mean:

No output means nothing is listening: the port is free, and the error came from something else, like a second copy of the server racing the first.

2. Check what it is

node doesn't tell you much. To see the full command, and which project it belongs to:

ps -o pid,etime,command -p 4821

ETIME is how long it's been running. A server started two days ago is almost certainly one you forgot.

3. Stop it

kill 4821

This asks the process to quit, so it can shut down cleanly. Check it's gone by running the lsof line again. If it's still there after a few seconds, force it:

kill -9 4821

Or find and stop whatever is listening on a port in one go:

lsof -ti tcp:3000 -sTCP:LISTEN | xargs kill

-t prints only the process IDs, which xargs passes to kill. Keep -sTCP:LISTEN in this one especially, so it can't stop your browser.

Ports 5000 and 7000: AirPlay Receiver

On macOS Monterey and later, ports 5000 and 7000 are often taken by ControlCenter. That's AirPlay Receiver, which lets other Apple devices stream to your Mac. Don't kill it: ControlCenter runs your menu bar's Control Center and simply restarts.

Either:

The faster way

Steamie's Servers page lists every server listening on your Mac, grouped by the project it belongs to, with how long each has been up and whether it's reachable from other devices on your network. Stopping one is a click, and it never lists macOS's own services as yours to stop.

More guides