Kill the process on port 3000 on a Mac
Your dev server fails with EADDRINUSE, or starts on 3001, because something already listens on port 3000. To find that process and stop it in one go, run kill $(lsof -t -iTCP:3000 -sTCP:LISTEN).
Find what's using port 3000
lsof -nP -iTCP:3000 -sTCP:LISTEN
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME node 48213 you 23u IPv6 0x1f… 0t0 TCP *:3000 (LISTEN)
-iTCP:3000 picks the port, -sTCP:LISTEN shows only the server and not the browser tabs connected to it, and -nP skips name lookups so it answers instantly. The number under PID is what you stop.
The shorter lsof -i :3000 finds it too, but it also lists every browser connection, and without -P it prints the port as hbci, the name /etc/services gives port 3000.
Every command here works for other ports too. Swap in 5173 for Vite, 4200 for Angular or 8081 for React Native's Metro.
Stop the server on port 3000
kill 48213
kill sends SIGTERM, which lets the server close its connections and exit cleanly. If it's still listed a few seconds later, force it with kill -9 48213.
The one-liner at the top does both steps: -t makes lsof print only the PID, and kill gets it.
npx kill-port 3000 does the same without flags to remember, and takes several ports at once, as in npx kill-port 3000 5173. On a Mac it runs lsof and then kill -9, so the server gets no chance to shut down cleanly. That's fine for a dev server. Don't point it at a database's port.
Why did my dev server start on 3001?
Next.js and Vite don't fail when their port is taken. They move to the next one. next dev tries up to ten ports past 3000 and tells you which process was in the way:
Port 3000 is in use by process 48213, using available port 3001 instead.
It only does that when you didn't choose the port. With -p 3000 or PORT=3000, it stops with EADDRINUSE instead. Vite starts on 5173 and moves to 5174 the same way, unless you set server.strictPort.
Either way, the old server is still running on 3000 and still holds its memory. Stop it first, or every restart lands on 3001.
What's using port 5000 or 7000?
If lsof shows ControlCe there, it's Control Center's AirPlay Receiver, which lets nearby Apple devices stream to your Mac. lsof cuts command names to nine characters. Apple lists both ports as AirPlay ports, and it's why Flask, which defaults to 5000, can't start. It isn't a server you started, so don't kill it. Turn off AirPlay Receiver in System Settings › General › AirDrop & Continuity (AirDrop & Handoff before macOS 26), or run your server on another port.
When the server on port 3000 comes straight back
- A watcher restarted it. nodemon, pm2, turbo or a
concurrentlyscript start the server again when it dies. Find the parent withps -o pid,ppid,command -p 48213, then stop that, or press Ctrl-C in the terminal that runs it. For pm2:pm2 stop all. - A container has it. If the COMMAND column shows
com.docke(Docker Desktop'scom.docker.backend) or OrbStack's own process instead of node or python, a container published the port. Find it withdocker ps --filter publish=3000and stop it withdocker stop <name>. - lsof shows nothing, but the port is still taken. It belongs to another user or root. Run the same command with
sudoto see it.