Using netstat and lsof command to show which process using a Port on Mac/Linux
netstat will show the most useful statistic data of networking.
The above command will display the information related to the networking port of 8080.
These are the detailed meaning of options:
Note: On MacOs, we’re stuck with the BSD netstat which will not show you the process ID that is attached to a given port.
lsof will be a choice for Mac.
lsof will display all opened files of a process. We could also use it to find which process used a networking port, since TCP/IP sockets use file descriptors.
lsof -i will show which process communicating over the internet.