Port X is already in use

The text describes how to fix the “Port 3000 is already in use” error. It provides commands to identify the process occupying port 3000, such as using `lsof` on Linux or a PowerShell command on Windows, and then instructs the user to terminate that process using the `kill` command.
generated by gemma3:4b

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

Terminal window
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

Terminal window
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:

Terminal window
kill -9 56017

Windows

Here’s a simple PowerShell command (run as Admin) that finds and kills all processes using port 3000:

powershell (admin)
Get-NetTCPConnection -LocalPort 3000 | ForEach-Object {
Stop-Process -Id $_.OwningProcess -Force
}