Port X is already in use

If you’ve ever encountered the error message “Port 3000 is already in use” when trying to run a local server for your application, you know how frustrating it can be. This error occurs when another process on your machine is using port 3000, which is the default port used by many web servers. Whether you’re a beginner or an experienced developer, the techniques we’ll cover will help you quickly and easily resolve this common issue.

Table of Contents

Find the processes

sudo lsof -i :3000

It will give you the following result (given if any process is running on 3000 port)

COMMANDPIDNODENAME
node56017TCPlocalhost:hbci (LISTEN)

Kill

kill -15 \<PID>

If the above step is still not killing the process, I recommend using -9 argument. It kills the process immediately.

For example:

kill -9 56017