Kill Ubuntu process that is using a port
April 22, 2024
First you need to know the process ID (PID), you can find this running the following command.
sudo lsof -i :PORT
This command will list all processes using the specified port, along with their PID.
Then with the PID number and the kill command you can terminate it.
sudo kill PID
If sudo kill PID doesn’t remove the process, you might need to use a more forceful termination signal, such as SIGKILL.
Use the kill command with the -9 option to send the SIGKILL signal.
sudo kill -9 PID