How to check listening ports on MacOS

On macOS Big Sur and later, use this command:

sudo lsof -i -P | grep LISTEN

or to just see just IPv4:

sudo lsof -nP -i4TCP:$PORT | grep LISTEN
原文地址:https://www.cnblogs.com/mouseleo/p/14553245.html