Find which process is using a port on a Mac, and stop it
How to find the process listening on a port such as 3000 or 8080 on a Mac with lsof, and how to stop it safely.
How do I find what is using a port on a Mac?
lsof -nP -iTCP:8080 -sTCP:LISTENReplace 8080 with your port. The output gives the command name and PID.
How do I kill the process using the port?
kill <PID>Use kill -9 only if it ignores the first request. Closing the terminal tab that started it usually also stops it.
Why is the port in use when nothing is running?
A dev server or editor helper kept running after its window closed. Cursor and orphaned node processes is a common case.
Common questions
How do I free port 3000 on Mac?
Find the PID with lsof -nP -iTCP:3000 -sTCP:LISTEN, then kill that PID.
How do I list all listening ports on Mac?
lsof -nP -iTCP -sTCP:LISTEN lists every process listening on a TCP port.