Find (and kill) process locking port 5000 or 5001 on Mac


Once in a while we see an error message like this on

(5000) is already in use

(5001) is already in use

Your immediate question would be what is running on this port and how to kill it?

Step1 : Find these processes:

$sudo lsof -i :5000

It is important to use sudo. Without sudo the lsof command only finds the ports started in the user space. Your goal is to find and kill any app using that port.

Typically port 5000 and 5001 are used by the $firebase serve command. Both the ports are required for $firebase serve to work fine.

Step 2: Kill

$sudo kill -9 <pid>

Here also sudo is import as the process may have been started by the system

Step 3:

If you are reading this steps means the system is restarting the app that was using the ports. In that case you would want to go to Applications folder and remove the application altogether, if it is not required anymore.

(5001) is already in use