LightAtom

How to Scan Ports on Mac (nc and nmap)

Check which ports are open on a host with nc, built into macOS, or nmap, the full-featured scanner. Only scan devices you own or have permission to test.

nc -zv 192.168.1.1 20-100

Check TCP ports 20–100 on your router with the built-in netcat.

intermediate10 minNeeds: Homebrew for nmap, Permission to scan the target

When to use it

Scan your own devices to see what's exposed: which services your router, NAS or server offers, or whether a port you opened is reachable on the local network. Scanning other people's systems without permission may break laws or terms of service.

Steps

  1. Check one port with nc

    -z only checks the connection without sending data; -v reports the result; -w sets a timeout.
    nc -zv -w 2 192.168.1.1 443
  2. Check a range with nc

    nc accepts ranges. Each closed port prints a refusal, each open one “succeeded”.
    nc -zv -w 1 192.168.1.1 20-100 2>&1 | grep succeeded
  3. Install nmap

    nmap gives faster scans, service detection and nicer output.
    brew install nmap
  4. Scan with nmap

    Without options, nmap scans the 1,000 most common TCP ports. -sV detects service versions.
    nmap -sV 192.168.1.1
  5. Find devices on your network

    -sn pings the whole subnet without scanning ports.
    nmap -sn 192.168.1.0/24

Output explained

nc on a Mac:

Connection to 127.0.0.1 port 4321 [tcp/rwhois] succeeded!
nc: connectx to 127.0.0.1 port 4322 (tcp) failed: Connection refused

nmap:

PORT    STATE    SERVICE
53/tcp  open     domain
80/tcp  open     http
443/tcp open     https
22/tcp  filtered ssh
  • open: something accepts connections.
  • closed: the host answered that nothing listens.
  • filtered: no answer, usually a firewall dropping probes.
  • The service name in brackets (tcp/rwhois) comes from the standard port list, not from what's actually running.

Options and variations

FlagMeaningExample
nc -zScan without sending datanc -z host 80
nc -uUDP (unreliable for scanning)nc -zu host 53
nmap -p LISTPorts to scannmap -p 22,80,443 host
nmap -sVDetect service versionsnmap -sV host
nmap -snHost discovery onlynmap -sn 192.168.1.0/24
sudo nmap -sSSYN scan (faster, needs root)sudo nmap -sS host

Common errors

ErrorCauseFix
All ports filteredA firewall drops probes, or the host is downPing the host; try from the same network.
nc hangsNo timeout on a filtered portAdd -w 1.

Do it in the app

To see what your own Mac exposes, you don't need a scan: LightAtom's Ports view lists every listening port and whether it's reachable from the network.

Frequently asked questions

How do I scan ports on a Mac without installing anything?

Use nc, built into macOS: nc -zv -w 1 host 1-1024 checks a range of TCP ports and reports which accept connections.

How do I install nmap on a Mac?

Install Homebrew, then run brew install nmap. The official nmap.org installer package also works.

Is port scanning legal?

Scanning your own devices is fine. Scanning systems you don't own can violate laws or provider terms in many countries; get permission first.

How do I see open ports on my own Mac?

Run sudo lsof -nP -iTCP -sTCP:LISTEN, or use LightAtom's Ports view. Scanning yourself from outside only shows what's reachable past your firewall.

LightAtom team

The people who build LightAtom, a network monitor for macOS.