How to view pid of process listening on port using netstat on macOS? 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?
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 &quot;*.80&quot;
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/