How to find which program or process is listening on a certain port in Linux?
Posted on In QAMy program reports that the port is already used.
How to find which program or process is listening on a certain port in Linux?
You can use netstat to do this. netstat can print network connections.
For example, to find which program is listing on port 9999
netstat -pln | grep 9999
You will need to use sudo
to get more details, such as process names that are now owned by you.
sudo netstat -pln | grep 9999
Here, p
makes netstat print process name, ‘l’ means “listening” and ‘n’ means numerical addresses instead of trying to determine symbolic host, port or user names.
If you are sure that the programming is using TCP or UDP, you can also add option t
or u
to filter out only TCP and UDP connections like
sudo netstat -ptln | grep 9999
sudo netstat -puln | grep 9999
For more details, please check netstat manual.