Check if a remote port is open with `nc -zv`

The fastest way to answer 'is the firewall blocking me?' — netcat in scan mode attempts one TCP connection and prints whether it succeeded.

LinuxncportnetcattroubleshootingLow risk
Run `nc -zv example.com 443` to test a single TCP port; `succeeded` means open and `Connection refused` or a timeout means closed or filtered.

01Command

Command
$ nc -zv example.com 443

02What it does

`-z` puts nc into zero-I/O mode: it opens a connection and closes it immediately without sending any payload, which is exactly what a port check needs. `-v` prints the result in plain words instead of relying on the exit code. Add `-w 3` to avoid hanging on filtered ports, and `-u` to test UDP (results are unreliable since UDP has no connection state).

03Risk

RiskLow risk
RequirementsRequires netcat-openbsd (apt install netcat-openbsd / dnf install nmap-ncat)
!Warning: A timeout usually means a firewall is silently dropping packets, while 'Connection refused' means the host answered but nothing listens on that port.

04Undo

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

05Sources

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

06Related solutions