How to kill a process on a port?

In this article let’s discuss about How to kill a process on a port?. Let’s go through the following methods without any delay.

Method 1:

#To list any process listening to the port 8080:
lsof -i:8080

#To kill any process listening to the port 8080:
kill $(lsof -t -i:8080)

#or more violently:
kill -9 $(lsof -t -i:8080)

If you are facing any issues with the above approach then try the alternative that is given below. It may look similar but have a try!

Method 2 :

netstat -ano | findstr "PORT_NUMBER"

taskkill /PID PORT_NUMBER /f

Hope the above solution works.

Realted Posts : Configuring git user and password