After installing an application that required port 8080, the application failed to start because the port was already in use. Changing the new application to use port 8090 worked, but it still left the question of what was running on 8080. As on Windows, Linux provides a command‑line utility, netstat, which can be used to inspect open ports and the programs that are bound to them. With the right options, the output makes it easy to see which process is listening on a specific port.
The following command shows all processes using port 8080 (or any port you specify):
netstat -anp | grep 8080
Replace 8080 with another port number as needed. This command lists matching sockets along with their addresses, state, and the PID/program name.
To understand what the options do, append --help to the command (for example, netstat --help or grep --help). The options used in this example are:
-a,--all,--listening– display all sockets (not only established connections)-n,--numeric– show numerical addresses and ports, don’t resolve names-p,--programs– show the PID/program name for each socket
The grep command filters the netstat output and displays only those lines that contain the specified port number, making it easier to see exactly which process is using that port.
