I am Utpal Vishwas from Uttar Pradesh. Have completed my B. Tech. course from MNNIT campus Prayagraj in 2022. I have good knowledge of computer networking.
There are a few ways to kill a process running on a particular port in Linux. Here are two methods:
Method 1: Using the netstat command
The netstat command is a command-line utility that displays network statistics. You can use the
netstat command to find the process that is using a specific port.
To do this, follow these steps:
Open a command prompt.
Run the following command:
netstat -ano | findstr :PORT
Replace PORT with the port number that you want to find the process for. For example, to find the process that is using port 8080, you would run the following command:
netstat -ano | findstr :8080
This will display a list of all the processes that are using port 8080. The process ID (PID) of the process will be listed in the second column.
Once you have found the PID of the process, you can use the kill command to kill the process.
To do this, run the following command:
kill -9 PID
Replace PID with the PID of the process that you want to kill. For example, to kill the process with PID 1234, you would run the following command:
kill -9 1234
Method 2: Using the fuser command
The fuser command is a command-line utility that can be used to find and control processes that are using a specific port.
To do this, follow these steps:
Open a command prompt.
Run the following command:
fuser -n TCP :PORT
Replace PORT with the port number that you want to find the process for. For example, to find the process that is using port 8080, you would run the following command:
fuser -n TCP :8080
This will display a list of all the processes that are using port 8080. The process ID (PID) of the process will be listed in the first column.
Once you have found the PID of the process, you can use the kill command to kill the process.
To do this, run the following command:
kill -9 PID
Replace PID with the PID of the process that you want to kill. For example, to kill the process with PID 1234, you would run the following command:
kill -9 1234
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
There are a few ways to kill a process running on a particular port in Linux. Here are two methods:
Method 1: Using the
netstatcommandThe
netstatcommand is a command-line utility that displays network statistics. You can use thenetstatcommand to find the process that is using a specific port.To do this, follow these steps:
Replace
PORTwith the port number that you want to find the process for. For example, to find the process that is using port 8080, you would run the following command:This will display a list of all the processes that are using port 8080. The process ID (PID) of the process will be listed in the second column.
killcommand to kill the process.To do this, run the following command:
Replace
PIDwith the PID of the process that you want to kill. For example, to kill the process with PID 1234, you would run the following command:Method 2: Using the
fusercommandThe
fusercommand is a command-line utility that can be used to find and control processes that are using a specific port.To do this, follow these steps:
Replace
PORTwith the port number that you want to find the process for. For example, to find the process that is using port 8080, you would run the following command:This will display a list of all the processes that are using port 8080. The process ID (PID) of the process will be listed in the first column.
killcommand to kill the process.To do this, run the following command:
Replace
PIDwith the PID of the process that you want to kill. For example, to kill the process with PID 1234, you would run the following command: