Mac/Linux: Show all used ports

Submitted by Peter Majmesku on Tue, 12/12/2017 - 14:09


sudo lsof -i -n -P


netstat -tulpen

Show if a port is opened on an endpoint

Check via Netcat (Mac and Linux only). A failed connection (432 is a port, which I have chosen randomly):

/mnt/c/Users/jepster/Dev/$ nc -v 432
nc: connect to port 432 (tcp) failed: Connection refused

A successful connection (port 25 is used for SMTP, needed for mail retrieval in mailserver):

/mnt/c/Users/jepster/Dev/$ nc -v 25
Connection to 25 port [tcp/smtp] succeeded!
220 ESMTP Haraka/2.8.23 ready