Test if a Remote Port Is Open with nc
Probe a host and port with nc -z to see if the service accepts connections.
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 44302What 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
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- nc — arbitrary TCP and UDP connections and listens (macOS man page)Evidence: Documents nc -z to scan for open ports without sending data, -v for verbose output and -G as the TCP connection timeout.
Last verified: 2026-09-18 · Category: Network