Test if a Remote Port Is Open with nc

Probe a host and port with nc -z to see if the service accepts connections.

macOSnetworkncportLow risk
Run `nc -z -v -G 5 example.com 443` — 'succeeded' means the port is open and reachable; 'Operation timed out' or 'refused' means it is blocked or closed.

01Command

Command
$ nc -z -v -G 5 example.com 443

02What it does

This answers a question ping can't: ping tests that the host is alive, while nc -z tests that a specific door on it is open. 'Connection refused' means the host answered but nothing listens on that port; a timeout usually means a firewall is silently dropping you. Swap 443 for 22 (SSH), 445 (SMB), 548 (AFP) or any port you need to reach.

03Risk

RiskLow risk
Requirementsnc ships with macOS; -G 5 caps the connection timeout at 5 seconds.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-09-18 · Category: Network