Question: How do I find out what Linux programs are using my ports?
Answer: Running a Linux dedicated server can be a big responsibility, so it is good to know shortcuts for some of the more sticky situations that arise. If you ever have a situation where you cannot start a critical service like Apache or MySQL because the port that it uses is being used by another application, there is a way to find out exactly what is going on.
To find out which processes are using which ports, login to your server through SSH and type:
This will bring up a list looking something like this:
tcp 0 0 0.0.0.0:631 0.0.0.0:* LISTEN 3941/cupsd
tcp6 0 0 :::22 :::* LISTEN 3158/sshd
The numbers after the colons tell you the port addresses being used. For example, CUPS printing service is using port 631, and SSHD is using port 22. Once you find out the rogue process, you can kill it and resume normal operation.
Photo Source: Flickr