Question
How can I test communication over a given port?
Process
Confirm something is listening on the desired port
Confirm that the target machine is listening on the expected port by running the below command in PowerShell on the client machine, where <port> is the port to check:
Get-NetTCPConnection -LocalPort <port>
If no results are returned, there isn't a process listening on the specified port.
If nothing is listening on the desired port
If an installed component is expected to be listening on a given port, confirm that the associated service/process is running, and that its log doesn't report any errors.
If you have not yet installed a component to listen on the desired port, the following can be run in PowerShell on the target machine to open a listener, where <port> is the port to desired port:
$Port = <port> $Listener = [System.Net.Sockets.TcpListener]$Port; $Listener.Start(); while ($true) { $client = $Listener.AcceptTcpClient(); Write-Host "Received connection from" ($client.Client.RemoteEndPoint).Address.ToString(); $client.Close(); } $Listener.Stop();
Note: The specified listener will continue running until the PowerShell window is closed:
Try to connect to the target over the desired port
To test if two machines can communicate over a given port, run the below command in PowerShell on the client machine, where <target> is the target machine and <port> is the desired port:
Test-NetConnection -Computer <target> -Port <port> -InformationLevel Detailed
Note: This tests if the specified port is open, but does not establish a connection to that port. It is possible for this test to report success but for connections to that port to still be inhibited by third-party security software and traffic/packet shapers.