How to determine which process is using a port in linux?

by ari.olson , in category: General Help , a month ago

How to determine which process is using a port in linux?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by benny_schoen , 25 days ago

@ari.olson 

To determine which process is using a specific port in Linux, you can use various commands and tools. Here are three commonly used methods:

  1. Using the netstat command: Open a terminal and run the following command: sudo netstat -tuln | grep PORT_NUMBER Replace PORT_NUMBER with the specific port number you want to check. The output will list the process ID (PID) and process name (COMMAND) using that port.
  2. Using the ss command: Open a terminal and run the following command: sudo ss -tuln | grep PORT_NUMBER Replace PORT_NUMBER with the specific port number you want to check. The output will provide details including the process PID and name.
  3. Using the lsof command: Open a terminal and run the following command: sudo lsof -i :PORT_NUMBER Replace PORT_NUMBER with the specific port number you want to check. The output will show the process details using that port, including the process ID and name.


Note: In all the above methods, running as root or with sudo privileges may be required to get complete information about all processes.