kill process on port

How to Kill Process Running on Specific Port

Sometimes you may need to kill process running on a particular port in your system. In this article, we will look at how to kill process running on specific port on Windows and Linux.


How to Kill Process Running on Specific Port

We will look at how to kill processes running on specific port in Windows & Linux. We will look at how to kill process running on port 80.


Windows

On windows, open command prompt and enter the following command.

c:\> netstat -ano | findstr :80

The last column of the output will display process ID.

You can kill the processes using taskkill command. Here is its syntax.

taskkill /PID <PID> /F

Here is the command to kill our process running on port 80.

taskkill /PID 3740 /F


Linux

Open terminal and run the following command to find processes running on port 80.

$ sudo lsof -i:80

To kill this process, run the following command.

$ sudo kill $(lsof -t -i:80)
OR
$ sudo kill -9 $(lsof -t -i:80)

You may also use fuser command similarly, as shown.

$ sudo fuser 80/tcp
OR
$ fuser -k 80/tcp

In this article, we have learnt how to kill process running on a specific port.

Also read:

Sed Command to Delete Lines in Linux
How to Install & Use Wine in Linux
How to Iterate Over Multiple Lists in Parallel in Python
How to List All Files in Directory in Python
How to Send HTML Email with Attachment in Python

Leave a Reply

Your email address will not be published.