What is the equivalent of Linux's netstat -tln on OS X?


-l, --listening (Show only listening sockets. (These are omitted by default.)
--numeric , -n (Show numerical addresses instead of trying to determine symbolic host, port or user names.)
-t, --tcp
  • 1
    What does netstat -tln actually do?
    – nohillside
    Nov 24, 2014 at 9:04
  • You can just open a Terminar an execute on it. It will work.
    – jherran
    Nov 24, 2014 at 9:07
  • 2
    @jherran No, OS X is using a BSD-based netstat which accepts different sets of options.
    – lolski
    Nov 24, 2014 at 9:13
  • @patrix in Linux, it lists all open TCP ports on the machine, and whether it listens locally ( or to remote connections (
    – lolski
    Nov 24, 2014 at 9:16

3 Answers 3


Should be this command:

sudo lsof -iTCP:$PORT -sTCP:LISTEN 

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

  • 1
    OP question didn't have a port argument, this answer requires one. This gives a useful command apple.stackexchange.com/a/327967/209603
    – goetz
    Dec 6, 2018 at 18:31
  • 6
    @goetzc Just use -iTCP instead of -iTCP:$PORT.
    – Navin
    Dec 24, 2018 at 9:00
  • 4
    I would add -P since OP specified -n in their question. Also +1 to @Navin. sudo lsof -iTCP -sTCP:LISTEN -P is closer to netstat -tln
    – seeafish
    Nov 7, 2019 at 15:28

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .