How to find what process is listening on a certain port?
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to find what process is listening on a certain port?
Hi,
I'm using Ubuntu Linux 11.04. I want to figure out what process is listening on port 4444. I tried the following, but it lists a bunch of processes, and only one can listen on port 4444 ...
Ideally, I could just run a command that would return a single process ID. Any ideas how to modify the above or know of a different command to use? - Dave
eSelix, I tried your solution, but didn't get my process ID, only
Code:
netstat -lp --numeric-ports --protocol=inet | grep :4444
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
However, I'm successfully able to "telnet localhost 4444" and the process runs as a non-root user. I'm using bash shell, Ubuntu 11.04. Does your solution apply to some other setup?
Josh, What were you trying to show with "lsof +M -i4"? That doesn't show me my process that is listening on 4444.
Josh, What were you trying to show with "lsof +M -i4"? That doesn't show me my process that is listening on 4444.
Thanks, - Dave
That was me failing to show you how to do it a different way
I normally use just the -i flag with lsof, but the +M -i4 was something that I was experimenting with a few days ago, and completely forgot that it doesn't show the actual numerical value of the port for the service on your system.
I used the "telnet localhost 4444" to demonstrate that there was a process running on the machine listening at 4444, so theoretically, the command above should have returned its process id.
So "lsof" works for you too. For "netstat" I don't known why ipv6 is not displayed, as I am not using it. Maybe this is by option "--protocol=inet" or you can add option "-6"
On Debian, it reports nothing. Reading /etc/services in Debian verifies that nothing was configured to listen on port 4444. Rather, in Debian, kerberos is configured to listen on ports 88, 749, 750, and 751.
Hi, Thanks for that, but I didn't register my process as a service, so nothing is appearing. Not to lose sight of what I was originally looking for, I just need an expression that will return the PID (and nothing else), of the process running on port 4444.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.