Skip to content

netstat command in MacOS

The netstat command in MacOS allows users to display network connections, routing tables, interface statistics, masquerade connections, and multicast memberships. It helps troubleshoot network issues and monitor network activity effectively.

Terminal window
netstat [ options ] [ parameters ]
OptionDescription
-a, —allShow both listening and non-listening sockets.
-t, —tcpDisplay TCP protocol sockets.
-u, —udpDisplay UDP protocol sockets.
-i, —interfacesShow network interfaces.
-r, —routingDisplay the kernel routing tables.
-s, —statisticsDisplay network statistics.
-p, —programsShow process using sockets.
-A family, —address-family=familyShow only sockets of specified address family: inet, inet6, unix.
-n, —numericShow numerical addresses.
-l, —listeningShow only listening sockets.
-c, —continuousContinuously display information.
-F form, —fib=filenameDisplay routing information from file.
ParameterDescription
destinationDisplay routing information for the specified destination.
interfaceDisplay information specific to the given network interface.
protocolDisplay information for the specified protocol (tcp, udp, etc).
hostDisplay information for the specified host.
portDisplay information for the specified port.
Terminal window
netstat -l

Display a list of all listening ports on the system.

Terminal window
netstat -s

Show statistics for all networking protocols.

Terminal window
netstat -r

Show the kernel routing table.

Display PID and Program for Each Connection

Section titled “Display PID and Program for Each Connection”
Terminal window
netstat -p

Display the PID and program name for each connection.

Terminal window
netstat -i

Display network interface statistics.

Terminal window
netstat -4

Show only IPv4 connections.

Terminal window
netstat -t

Show only TCP connections.

Terminal window
netstat -u

Show all listening UDP ports on the system.

To use the netstat command in MacOS, execute the following command:

Terminal window
netstat --option <value>

How can I display active network connections with netstat in MacOS?

Section titled “How can I display active network connections with netstat in MacOS?”

To display active network connections in MacOS using netstat, run the following command:

Terminal window
netstat -an

How do I check for listening ports with netstat on MacOS?

Section titled “How do I check for listening ports with netstat on MacOS?”

To check for listening ports in MacOS using netstat, use the following command:

Terminal window
netstat -tuln

How to show the PID/Program name along with network connections in MacOS using netstat?

Section titled “How to show the PID/Program name along with network connections in MacOS using netstat?”

To display the PID/Program name along with network connections in MacOS using netstat, execute the command below:

Terminal window
netstat -ap

How do I filter netstat output by a specific protocol in MacOS?

Section titled “How do I filter netstat output by a specific protocol in MacOS?”

To filter netstat output by a specific protocol in MacOS, use the following command:

Terminal window
netstat -t -p tcp

How can I show the routing table in MacOS using netstat?

Section titled “How can I show the routing table in MacOS using netstat?”

To display the routing table in MacOS using netstat, run the following command:

Terminal window
netstat -nr

How to display statistics for each protocol using netstat in MacOS?

Section titled “How to display statistics for each protocol using netstat in MacOS?”

To display statistics for each protocol in MacOS using netstat, execute the following command:

Terminal window
netstat -s

How do I show both listening and non-listening sockets in MacOS using netstat?

Section titled “How do I show both listening and non-listening sockets in MacOS using netstat?”

To show both listening and non-listening sockets in MacOS using netstat, use the following command:

Terminal window
netstat -a

How can I display only the numeric values in the output of netstat on MacOS?

Section titled “How can I display only the numeric values in the output of netstat on MacOS?”

To display only numeric values in the output of netstat in MacOS, run the following command:

Terminal window
netstat -n
  • Display network connections
  • Display routing table information
  • Display interface statistics
  • Display multicast group information
  • Display network protocol statistics