How to kill a process if its port is known? For example if a process is running at port
12345 then how it can be terminated in linux/ubuntu.
migrated from stackoverflow.com Oct 7 '13 at 13:09
This question came from our site for professional and enthusiast programmers.
You can use
to show what is listening on what port. You should see something similar to this (I've simplified the output somewhat).
That fourth column (0.0.0.0:80 in my example) will show you the port number (80 here) and the final column (2472/apache2) will show you the PID (2472).
You can then issue
where PID is the PID we found with the previous command. This will send SIGTERM to the process. If that fails, you may need to
but that is generally a less friendly way to kill process. For more info, you should checkout