[Shell command] Check whether a TCP port accepts a connection

Created on November 30, 2026

You can use nc -zv to check whether you can open a TCP connection. -z probes the port without sending application data, and -v prints the result. This example checks port 80 on the local machine.

nc -zv localhost 80

On success you may see Connection to localhost 80 port [tcp/http] succeeded!. If no process is listening, you may see a Connection refused error. The exact message depends on the netcat implementation.

Shell command