Find which process is listening on a particular port
til command-line
Use the lsof
(list of open files) command to figure out which process is listening to a particular port
$ lsof -i:8080
The output looks something like the following:
$ lsof -i:8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 950 raj 9u IPv4 0x6e63a6f59d9b8a7f 0t0 TCP 127.0.0.42:http (LISTEN)
nginx 1060 raj 9u IPv4 0x6e63a6f59d9b8a7f 0t0 TCP 127.0.0.42:http (LISTEN)
If you are interested in just the PIDs, use the -t
option to get a terse output
$ lsof -t -i:8080
950
1060
Here is the man page for further options/reference.