How do I find (and kill) process running on a certain port? [duplicate]
Possible Duplicate:
Finding the process that is using a certain port in Linux
I'm using Ubuntu Linux 11.04. How do I write a shell script expression that will find the process running on port 4444 and then kill the process?
Solution 1:
You could use lsof
to find the process:
lsof -t -i:4444
would list only the pid of the process listening on port 4444. You could just say
kill `lsof -t -i:4444`
if you were brave.
Solution 2:
You use lsof
:
# lsof -n | grep TCP | grep LISTEN | grep 4444
The output will be something like:
pname 16125 user 28u IPv6 4835296 TCP *:4444 (LISTEN)
Where the first column is the process name, and the second column is the process id. You then parse the output, find out what the process id (PID) is and use kill
command to kill it.