How to List All Ports in Use

See every listening port on your system and which process owns it. Works on macOS, Linux, and Windows.

Updated April 20265 min read

Quick method: portrm scan

One command to see all ports, PIDs, process names, and commands across all operating systems:

$ ptrm scan
  PORT   PID     NAME           CMD
  22     1       sshd           /usr/sbin/sshd
  80     44219   nginx          nginx: worker process
  443    44219   nginx          nginx: worker process
  3000   67890   node           next-server
  5432   1234    postgres       /usr/lib/postgresql/16/bin/postgres
  6379   5678    redis-server   redis-server *:6379
  8080   19432   java           java -jar app.jar
  9090   42187   grafana        grafana server
  Found 8 ports in use

macOS: lsof

# All listening ports
$ lsof -i -P -n | grep LISTEN

# TCP only
$ lsof -iTCP -sTCP:LISTEN -P -n

# Specific port
$ lsof -i :3000

Flags: -P shows port numbers (not names), -n skips DNS lookup (faster).

Linux: ss (recommended)

# All listening TCP ports with process info
$ ss -tlnp

# All listening UDP ports
$ ss -ulnp

# Both TCP and UDP
$ ss -tulnp

# Filter by port
$ ss -tlnp sport = :8080

Flags: -t TCP, -u UDP, -l listening, -n numeric, -p show process.

Linux: netstat (legacy)

# All listening ports
$ netstat -tlnp

# Include UDP
$ netstat -tulnp

Install if missing: sudo apt install net-tools

Windows: netstat

# All listening ports with PIDs
> netstat -ano | findstr LISTENING

# With process names (elevated prompt)
> netstat -anob

Windows: PowerShell

# Clean table output
> Get-NetTCPConnection -State Listen |
    Select-Object LocalPort, OwningProcess,
    @{Name="Process";Expression={(Get-Process -Id $_.OwningProcess).Name}} |
    Sort-Object LocalPort |
    Format-Table -AutoSize

Comparison table

ToolOSShows PIDsShows process nameSpeed
ptrm scanAllYesYes + commandFast (Rust)
lsofmacOS, LinuxYesYesModerate
ssLinuxYesYesFast
netstatAllYesWith -b (Windows)Slow
fuserLinuxYesNoFast

Filter by port range

# Show only dev ports (3000-9999)
$ ptrm scan --range 3000-9999

# With lsof (macOS/Linux)
$ lsof -i -P -n | grep LISTEN | awk '$9 ~ /:[3-9][0-9]{3}$/'

One command. Every port. Every OS.

portrm scan shows all listening ports with process names, PIDs, and commands in a clean table. No flags to memorize.