nc -zv 192.168.1.1 20-100Check TCP ports 20–100 on your router with the built-in netcat.
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
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 443Check 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 succeededInstall nmap
nmap gives faster scans, service detection and nicer output.brew install nmapScan with nmap
Without options, nmap scans the 1,000 most common TCP ports. -sV detects service versions.nmap -sV 192.168.1.1Find 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
| Flag | Meaning | Example |
|---|---|---|
| nc -z | Scan without sending data | nc -z host 80 |
| nc -u | UDP (unreliable for scanning) | nc -zu host 53 |
| nmap -p LIST | Ports to scan | nmap -p 22,80,443 host |
| nmap -sV | Detect service versions | nmap -sV host |
| nmap -sn | Host discovery only | nmap -sn 192.168.1.0/24 |
| sudo nmap -sS | SYN scan (faster, needs root) | sudo nmap -sS host |
Common errors
| Error | Cause | Fix |
|---|---|---|
| All ports filtered | A firewall drops probes, or the host is down | Ping the host; try from the same network. |
| nc hangs | No timeout on a filtered port | Add -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.