HostOnNet Blog

Find which program use a port

Looking for Linux Server Admin or WordPress Expert? We can help.

To find which program use a port, for example 8080, you can use netstat or fuser command.

ufser

fuser command is part of psmisc package. On CentOS, install it with

yum install psmisc

To see which application is running on PORT 8080, run

fuser -vn tcp 8080

Example

[root@ip-10-0-51-171 ~]# fuser -vn tcp 8080
                     USER        PID ACCESS COMMAND
8080/tcp:            root       4747 F.... httpd
                     apache     4749 F.... httpd
                     apache     4750 F.... httpd
                     apache     4751 F.... httpd
                     apache     4752 F.... httpd
                     apache     4753 F.... httpd
                     apache     4754 F.... httpd
                     apache     4756 F.... httpd
[root@ip-10-0-51-171 ~]#

netstat

netstat have an option -p, that shows process ID.

To find which program is using port 8080, run

netstat -anp | grep LIST | grep 8080

Now you get process ID, use ps aux to find the process with that ID.

Example


[root@ip-10-0-51-171 ~]# netstat -anp | grep LIST | grep 8080
tcp        0      0 127.0.0.1:8080          0.0.0.0:*               LISTEN      4747/httpd          
[root@ip-10-0-51-171 ~]# ps aux | grep 4747
root      4747  0.0  1.1 471928 21656 ?        Ss   03:20   0:00 /usr/sbin/httpd -DFOREGROUND
root      6099  0.0  0.0 112648   952 pts/1    R+   03:47   0:00 grep --color=auto 4747
[root@ip-10-0-51-171 ~]# 

Posted in Linux

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.