List open ports on your machine (Mac OS X)
August 08, 2007
netstat on Mac OS X is not what you might be used to on a Linux machine (on Linux you can use netstat -atp | grep -i "listen"). To show all open ports applications on your machine are listening to you can use this workaround:
macbook:~ sudo lsof -i -P | grep -i "listen"
netinfod 33 root 7u IPv4 0x3f76e08 0t0 TCP localhost:1033 (LISTEN)
AppleFile 142 root 29u IPv6 0x3973c50 0t0 TCP *:548 (LISTEN)
AppleFile 142 root 30u IPv4 0x3f76018 0t0 TCP *:548 (LISTEN)
mysqld 175 mysql 11u IPv4 0x415c018 0t0 TCP *:3306 (LISTEN)
slpd 214 root 2u IPv4 0x415c710 0t0 TCP *:427 (LISTEN)
eclipse 277 stefans 23u IPv6 0x39733a0 0t0 TCP *:8118 (LISTEN)
eclipse 277 stefans 25u IPv6 0x3973a24 0t0 TCP *:49372 (LISTEN)
eclipse 277 stefans 27u IPv6 0x51d20e0 0t0 TCP *:6836 (LISTEN)
eclipse 277 stefans 29u IPv6 0x51d2764 0t0 TCP *:14685 (LISTEN)
cupsd 279 root 0u IPv4 0x3f75c9c 0t0 TCP localhost:631 (LISTEN)
java 1037 stefans 7u IPv6 0x3972d1c 0t0 TCP *:1527 (LISTEN)
java 1052 stefans 9u IPv6 0x3971538 0t0 TCP *:49979 (LISTEN)
java 1052 stefans 15u IPv6 0x3972f48 0t0 TCP *:44441 (LISTEN)
java 1052 stefans 23u IPv6 0x51d4174 0t0 TCP *:49987 (LISTEN)
java 1118 stefans 12u IPv6 0x51d3240 0t0 TCP *:50055 (LISTEN)
java 1118 stefans 38u IPv6 0x568f3a0 0t0 TCP *:50061 (LISTEN)
java 1118 stefans 48u IPv4 0x3f76394 0t0 TCP *:8000 (LISTEN)
java 3422 stefans 11u IPv6 0x5a28de8 0t0 TCP *:51669 (LISTEN)
java 3422 stefans 13u IPv6 0x6111990 0t0 TCP *:8080 (LISTEN)
java 3422 stefans 14u IPv6 0x56af764 0t0 TCP *:8443 (LISTEN)
java 3422 stefans 37u IPv6 0x5f69764 0t0 TCP *:51672 (LISTEN)
Lsof [...] lists information about files opened by processes [...]. An open file may be a regular file, a directory, a block special file, a character special file, an executing text reference, a library, a stream or a network file (Internet socket, NFS file or UNIX domain socket.) A specific file or all the files in a file system may be selected by path.