netstat on Mac: The Complete Guide
How to use netstat on macOS to see ports, connections, routing, and network stats, plus how to see which process owns a port with netstat -v or lsof.
netstat is one of the oldest network tools on a Mac, and one of the most misunderstood, because the macOS version behaves differently from the Linux version people usually copy commands from. Here’s how it actually works on macOS, what it’s good at, and where it falls short.
The most important thing to know first
macOS netstat is the BSD version, not the Linux (GNU) one. The single biggest consequence: the Linux flags don’t work. The trick everyone pastes, netstat -tulpn, does not work on a Mac. The -p flag means something completely different here (it selects a protocol, not “show process”). macOS netstat can still show the owning process and PID, but you ask for it with -v instead.
So if your goal is “which app is using this port,” netstat -anv can answer it, though lsof gives much more readable output. Both are covered below.
List listening ports
The closest macOS equivalent to the classic “show me what’s listening”:
netstat -an | grep LISTEN
Sample output:
tcp4 0 0 *.3000 *.* LISTEN
tcp4 0 0 127.0.0.1.5432 *.* LISTEN
tcp6 0 0 *.8080 *.* LISTEN
Flag breakdown:
-a: show all sockets, including listening ones-n: show numeric addresses and ports (don’t resolve names, much faster)
Add a protocol filter to cut the noise:
# TCP only
netstat -an -p tcp | grep LISTEN
# UDP only
netstat -an -p udp
Here -p selects the protocol, this is the macOS meaning, not the Linux “process” meaning.
See all active connections
Drop the grep to see established connections too, not just listeners:
netstat -an -p tcp
The State column tells you what each connection is doing: LISTEN, ESTABLISHED, TIME_WAIT, CLOSE_WAIT, and so on.
Other things netstat is genuinely good at
Where macOS netstat shines is the network-level views that lsof doesn’t give you:
Routing table (which interface traffic takes):
netstat -rn
Per-interface statistics (packets in/out, errors, drops):
netstat -i
Protocol statistics (TCP retransmits, UDP errors, etc.):
netstat -s
# Just TCP stats
netstat -sp tcp
These are the commands worth keeping netstat around for. For “what’s listening and who owns it,” there are better tools.
Finding the process behind a port
This is the wall everyone hits with the Linux flags. Plain netstat -an shows that something is listening on port 3000, but not what. On macOS, add -v (verbose) and netstat prints a process:pid column:
netstat -anv -p tcp | grep LISTEN
tcp4 0 0 *.3000 *.* LISTEN ... node:1421 ...
tcp4 0 0 127.0.0.1.5432 *.* LISTEN ... postgres:1803 ...
Each line is very wide, with a dozen counters and flags around the process column, so it’s hard to read in a normal terminal window. lsof gives the same answer in a cleaner layout:
sudo lsof -iTCP -sTCP:LISTEN -n -P
COMMAND PID USER ... NODE NAME
node 1421 aaron ... TCP *:3000 (LISTEN)
postgres 1803 aaron ... TCP 127.0.0.1:5432 (LISTEN)
Now you can see node owns port 3000. For a specific port:
sudo lsof -i :3000 -n -P
See how to list open ports on Mac for the full lsof walkthrough, and which app is using a port if that’s all you need.
Quick reference
| Goal | Command |
|---|---|
| Listening ports | netstat -an | grep LISTEN |
| Listening ports with process | netstat -anv -p tcp | grep LISTEN |
| All TCP connections | netstat -an -p tcp |
| Routing table | netstat -rn |
| Interface stats | netstat -i |
| Protocol stats | netstat -s |
| Which process owns a port | sudo lsof -i :PORT -n -P |
Skip the flags entirely
If you mostly reach for netstat to answer “what’s open and who owns it,” Portie does that without any command at all. It shows every open TCP and UDP port on your Mac, the owning app, the protocol, and the connection state, in one live table that refreshes every 3 seconds, with the process names you’d otherwise dig out of netstat -v or lsof right there in the list.
Local monitoring is free. The $8.99 one-time unlock adds one-click process termination and remote port scanning. Download Portie and leave the netstat flags behind.