macOS Network – How to View PID of Process Listening on Port Using netstat

command linemacosNetwork

For *nix we can use

  netstat -anp

specifically the -p option. This is not supported on macOS. I also tried -b and -o which do not work. So how is this done on macOS?

Best Answer

Try using the -v option for verbose output. That will give, well, verbose results so you can filter a bit with -p and then maybe pipe to grep for your port number. Something like this to find the process using TCP protocol on port 80:

netstat -anv -p tcp | grep "*.80"

Here's a helpful resource with other options: https://www.btaz.com/mac-os-x/find-the-process-listening-to-port-on-mac-os-x/