Jul 18, 2025
This guide explains how to test port connectivity using the netcat command on Linux/MacOS and Test-NetConnection in Windows PowerShell.
nc <host> <port> to attempt a TCP connection to a host and port.<host> can be a domain or IP address; <port> can be a specific number or range.nc -u <host> <port> opens a UDP connection for protocols using UDP.nc -z <host> <port> scans for open ports without sending data.nc -v <host> <port> provides verbose output for debugging and troubleshooting.nc -vv <host> <port> gives even more detailed output than -v.nc -p <localport> <host> <port> specifies the local source port for the connection.nc -e <program> <host> <port> runs a program after a connection, not supported in all netcat versions.nc -n <addr> <port> bypasses DNS lookup, using only numeric address and port.nc -v -z <host> <port> to check for open ports with verbose output.Test-NetConnection <host> <port> to test connectivity to a host and port.-InformationLevel "Detailed" provides a detailed connectivity report.Test-NetConnection -ComputerName <host> checks connectivity to a remote host.-Port <port> to specify the target port.-DiagnoseRouting runs route diagnostics to the host, sometimes requiring admin rights.-ConstrainInterface <number> restricts the test to a specific network interface.-InformationLevel Detailed with routing diagnostics.nc and Test-NetConnection with different options to test port connectivity on your systems.