DEV Community

Nic
Nic

Posted on • Originally published at coderscat.com on

How to Find Which Process using a Networking Port

2020_06_08_how-to-find-which-process-used-a-networking-port.org_20200615_162735.png

netstat

Command netstat will show the most useful statistic data of networking.

netstat -ltnp | grep -w ':8080' 

Enter fullscreen mode Exit fullscreen mode

The above command will display the information related to the networking port of 8080.

These are the detailed meaning of options:

l – let netstat to only show listening sockets.t – let netstat to display TCP connections.n – show numerical addresses.p – enables showing of the process ID and the process name.grep -w – shows matching of exact string (:80).
Enter fullscreen mode Exit fullscreen mode

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.

So, lsof will be a choice for Mac.

lsof

Command 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.

2020_06_08_how-to-find-which-process-used-a-networking-port.org_20200615_161636.png

The post How to Find Which Process using a Networking Port appeared first on Coder's Cat.

Top comments (0)