Thursday, December 9, 2021

How to resolve port already in use or kill the running process

 On Linux:

step1: if the process is running at port 3000 then, firstly we have to kill this process for this open your terminal and type

lsof -w -n -i tcp:3000

which shows all the list of open file which is running at port 3000. Here, lsof stands for ls = list and of = opened file. You can see list with pid number.

step2: type sudo kill -9 6911 where 6911 is pid number. Here 9 has its own meaning which is defined as kill command "SIGKILL" you can see this by typing in the terminal as kill -l . You can use -SIGKILL instead of -9.

On Windows:

Open and run command prompt as administrator and type the following command:
   netstat -ano | findstr :8080

This command will find and list the process that uses this port 8080.

Now, we need to kill the process, for this use following command:

   taskkill /pid 5884 /f

Where 5884 is the PID number. Use the process PID number obtained previously.