On macOS Big Sur and later, use this command:
Big Sur
sudo lsof -i -P | grep LISTEN
or to just see just IPv4:
sudo lsof -nP -i4TCP:$PORT | grep LISTEN
How to check listening ports on MacOS
原文:https://www.cnblogs.com/mouseleo/p/14553245.html