How to find PID of a process which is running on a specific port

As a system admin, there are scenarios where you might need to find PID of a process which is running on a specific port. In JBoss administration this comes very handy as as we need to deal with hell lot of port numbers.

In this case, consider jboss is not started up due to the error , Port already in use 51314

You need to find the PID of the process which used the port 51314 and kill so that Jboss can have a clean start.

lsof is a command which help you here, with option -i and hostname:port.

lsof -i @jbsuat45:51315

Here jbsuat45 is the hostname and port is 51314

Now we get the PID and you can Kill it using Kill -9 command.

PS:

You can also find the process which are running by

netstat -ia | grep 51314

Add Comment