Apple - What is the equivalent of netstat -tln on OS X?

Should be this command:

sudo lsof -iTCP:$PORT -sTCP:LISTEN 

Who is listening on a given TCP port on Mac OS X?


The closest equivalent you can get on macOS is:

netstat -p tcp -van | grep '^Proto\|LISTEN'
  • tu options are not available, but they can be replaced by either -p tcp or -p udp, although you can't have both at the same time
  • -p option is replaced with -v which effectively gets you PIDs listed
  • -l option is not available, but you can work around it by using -a option (which includes servers in the listing) and grep LISTEN (to filter only for listening)

For real-time monitoring, try this:

nettop -p 60683

You can also restrict the interface type, like wifi or wired...

nettop -t wifi -n -p 60683

Tags:

Command Line