COMMAND

Test-NetConnectionTest a TCP port or host reachability

Test-NetConnection is the PowerShell cmdlet for testing network reachability. With -Port it attempts a TCP connection and reports whether the port is open, which replaces using telnet as a port tester. Without -Port it pings the host and shows the route and interface used.

BlackhawkHub Editorial · Updated

Purpose

Test-NetConnection answers "can I reach that service?" more precisely than ping. Because it opens a real TCP connection to a named port, it tests exactly what an application would do, and it works even when the host blocks ICMP so ping fails.

Testing a TCP port

powershell
Test-NetConnection example.com -Port 443
text
ComputerName     : example.com
RemoteAddress    : 93.184.215.14
RemotePort       : 443
InterfaceAlias   : Ethernet
SourceAddress    : 192.168.1.37
TcpTestSucceeded : True

TcpTestSucceeded : True means the port accepted a connection. False means closed, filtered or unreachable.

Ping and route diagnostics

powershell
Test-NetConnection example.com

Without -Port, it pings the host and reports PingSucceeded, the resolved address, and the interface and source address chosen, which is useful on multi-homed machines.

More detail

powershell
Test-NetConnection example.com -Port 443 -InformationLevel Detailed
Test-NetConnection example.com -TraceRoute

-InformationLevel Detailed adds the name-resolution results and all resolved addresses; -TraceRoute runs a route trace like tracert.

Common uses

  • Confirm a web server is listening on 443 before blaming DNS or the browser.
  • Check that a firewall change opened 3389 to a jump host.
  • Verify a mail server accepts connections on 25 from a network where outbound 25 is not blocked.
  • Diagnose a 502 by testing the proxy-to-backend port from the proxy host.

Common mistakes

  • Using it for UDP. It only tests TCP; a "False" for a UDP service is meaningless.
  • Testing from the wrong host. A port open to one network may be firewalled from another; test from where the real client sits.
  • Reading a False as "server down". Check PingSucceeded: a reachable host with a closed port is a service or firewall issue, not a connectivity one.

Older alternative

The classic telnet host port did the same TCP test but needs the Telnet client feature installed and gives a blank screen on success. Test-NetConnection is clearer and built in. See Telnet on port 23.

Frequently asked questions

Can Test-NetConnection test a UDP port?

No. It performs a TCP connect, so it works only for TCP services. UDP ports cannot be tested this way because there is no handshake; use the protocol's own client instead. See TCP vs UDP.

What does TcpTestSucceeded : False mean?

The TCP connection did not complete: the port is closed, a firewall dropped the packets, or the host is unreachable. The PingSucceeded line helps tell "host down" from "port closed on a reachable host".

Is there a shorter way to type it?

Yes: tnc host -Port 443 uses the alias. tnc host alone does a ping and route test.

Sources