How to test if a port is open on a remote machine

flag Scope

Verifying if a port is open on a remote machine.

construction How-to
There are 2 quick ways to check if a port is open on a remote host: Option 1 – Using Telnet

Assuming Telnet is installed on your Windows machine:
  1. Open a command prompt or a PowerShell
  2. Execute the following command:
  3. telnet "remote host" "port"

    Where:
    • remote host: : the IP or DNS name of the remote machine (Note: you can't specify a protocol, so google.com will work, while https://google.com won't)
    • port: the port number

So, if you want to test the connection to port 443 (HTTPS) on google.com simply run:
telnet google.com 443

There are two possible outcomes:
Option 2 – Using Telnet

The modern way to test a connection using the Test-NetConnection cmdlet:
  1. Open a PowerShell
  2. Execute the following command:
  3. Test-NetConnection -ComputerName "remote host" -Port "port number"

    Where (as in the previous paragraph):
    • remote host: : the IP or DNS name of the remote machine (Note: you can't specify a protocol, so google.com will work, while https://google.com won't)
    • port: the port number

So, if you want to test the connection to port 443 (HTTPS) on google.com run:
Test-NetConnection -ComputerName google.com -Port 443

The output will be similar to this:

    ComputerName      : google.com
    RemoteAddress     : 142.250.184.110
    RemotePort        : 443
    InterfaceAlias    : Ethernet
    SourceAddress     : 192.168.0.1
    TcpTestSucceeded  : True
                

You can check the outcome by looking at the last line, TcpTestSucceeded, which can be either true or false.
While it's not the quickest way to test a single port, the Test-NetConnection cmdlet has a lot of other useful options and use cases.
You can find the link to the documentation at the end of this page.

school Further considerations





Article ID: SYS-WIN-0009