The netstat command is available on Macs by default.

You don’t need to download or install it.

To run netstat:

Go toFinder>Go>Utilities.

Finder’s Go menu with Utilities highlighted

In the new Terminal window, typenetstatand pressReturn(orEnter) to execute the command.

A huge amount of text will begin scrolling on your screen.

A standard report can run over 1,000 lines.

Utilities folder with Terminal highlighted

Netstat’s built-in flags allow you to set options, limiting the command’s scope.

you’ve got the option to also view anonline version of netstat’s man page.

Using flags or syntax from those implementations of netstat may not result in the expected behavior.

Terminal window with the netstat command highlighted

It also uses verbose output, listing the PIDs associated with each connection.

The pipe character|sends the output of one command to another command.

Options within connection Utility are more limited than those available through the command line.

A lengthy netstat report in a Terminal window

Each of the four radio button selections runs a preset netstatcommand and displays the output.

Although it has its uses, netstat isn’t as useful on macOS as it is on Windows.

A different command,lsof, replaces much of the missing functionality.

The Netstat tab in Network Utility

Lsof displays files currently open in apps.

you’re free to also use it to inspect app-associated open ports.

Runlsof -ito see the list of applications communicating over the internet.

Network Utility > Netstat

Lsof Flags and Options

Displaying every open file or internet connection is typically verbose.

That’s why lsof comes with flags for restricting results with specific criteria.

The most important ones are below.

Lsof output

lsof Examples

Here are a few ways to use lsof.

It also lists the processes associated with those open ports.

This is a significant upgrade overnetstat, which lists PIDs at most.

Lsof listen command

FAQ

First, you need tofigure out the number of the portyou want to check.

You should see a computer’s MAC address through netstat as the “local” address.

It will be grouped with TCP (protocol) and the IP address (foreign).

Whoami command in Terminal