Skip to content


How To Display Which Processes Are Using What Ports

This is just a quick entry on how to see which software is using which ports. This comes in handy when trying to install an application server, web server, etc, and are getting errors like "port is in use".

Basically in any Unix type derivative such as Linux such (Ubuntu, RedHat, SuSe, etc.), as well as Mac OS X, all that you need to type this at the command line:

CODE:
  1. lsof -i

I remember there being a couple of commands in Windows which you could do this with, but it's been so long since I've used Windows on a regular basis I honestly don't remember how to do it. I do know you can use TCPView to accomplish the same thing, however.

Posted in Apache HTTPD, Apache Tomcat, Culture, FreeBSD, JBoss, Linux, MySQL, OS X, Operating Systems, PostgreSQL, Servers, Tips, Hacks, & Tricks, Windows. Tagged with , , , , , , , , , , , , .

3 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Bubbagimp said

    In Vista and XP SP2 you can run "netstat -b" and it will show the process associated with the port.

    In Vista the tricky part is, it requires an elevated command line window. The easiest way to do this I found is to type "cmd" in the search portion of the start menu and hit ctrl-shift-enter to elevate the process. Click continue to confirm the action. You have to do this even if your account is set to Administrator.

    Have I mentioned I hate Vista?

  2. Bubbagimp said

    Whoops, just to clarify -b shows the program that opened the port. The option -o shows the PID.

  3. Nice tip. I use 'netstat -anp | grep LISTEN' on Linux which usually runs faster than lsof. But it doesn't work the same on FreeBSD.

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.