Port already in use on Mac: find what holds it and free it
Updated · 2 min read
Error: listen EADDRINUSE: address already in use :::3000 means another process already listens on that port. On a Mac, two commands find it and stop it:
lsof -nP -iTCP:3000 -sTCP:LISTEN
kill 48213Put your port in place of 3000, and the number from the PID column in place of 48213.
Find the process
lsof -nP -iTCP:3000 -sTCP:LISTENCOMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 48213 you 23u IPv6 0x9c… 0t0 TCP *:3000 (LISTEN)-iTCP:3000looks at TCP port 3000.-sTCP:LISTENkeeps only the process that listens on it. Without it you also get every program connected to the port, your browser included.-nPprints numbers instead of names, so it answers faster.
Most of the time it's a dev server started earlier in a terminal tab you've since closed, or one that kept running after the tool that started it quit.
Which project is it?
Several node processes look alike. These two tell them apart:
ps -p 48213 -o command=
lsof -a -p 48213 -d cwdThe first prints the full command line. The second prints the folder the process runs in, in the NAME column.
Stop it
kill 48213kill asks the process to quit, so a server can close its connections first. If it's still listed a few seconds later:
kill -9 48213-9 can't be refused. Whatever the process hadn't saved is lost.
The one-liner, done safely
lsof -tiTCP:3000 -sTCP:LISTEN | xargs killMany answers online give lsof -ti :3000 | xargs kill. That version also matches programs connected to port 3000: if the page is open in your browser, it can close the browser along with the server. Keep -sTCP:LISTEN in.
npx kill-port 3000 does the same from npm, if you prefer.
When it isn't a dev server
ControlCeon port 5000 or 7000 is the AirPlay Receiver of macOS. Don't kill it: it comes straight back. See Port 5000 in use on Mac.- A
com.docker…process means a Docker container publishes the port.docker psshows which one, anddocker stopfrees it. - Nothing is listed, but the port is still taken: the process belongs to another user or to the system, and
lsofonly shows it withsudo. Pick another port rather than stopping it.
Or use another port
Most dev servers take a port option or read the PORT variable: PORT=3001 npm start, next dev -p 3001, vite --port 5174. When you don't recognise what holds the port, that's often the safer move.
How Portroom handles it
Portroom says what holds the port, and offers the next one
Portroom checks a project’s port before it starts the server. When the port is taken, the project says by what, such as node · PID 48213 · not started by Portroom, with Kill process for your own processes and Use 8768, the next free port.
Processes lists dev servers left running outside your projects, with folder and command. Stopping one takes two clicks, and Portroom checks first that it’s still the same process.


Something wrong or out of date on this page? Write to support@portroom.dev.