Test-Connection to a server succeeds, but Test-NetConnection with a specific port appears to hang. The same port test with -InformationLevel Quiet returns normally. It happens both on the same subnet and across a WAN. What should I check?
Why does Test-NetConnection hang when ping works?
Answers
Ping succeeding only tells you that ICMP traffic is getting through. It doesn't establish that the TCP port is reachable. The port could be blocked, or there might not be a service listening on it.
First, check the actual value of $Port and confirm the service is supposed to be listening on that server. A blocked connection can take a while to time out.
Reply to this answer
The Quiet result is the interesting part here. Does it return True or False, and how long does it take? If it returns True quickly, a simple blocked-port explanation doesn't account for the difference. If it returns False, compare the time it takes with the non-Quiet test.
Also check whether the non-Quiet command eventually finishes and what it reports. That should help narrow down whether the delay is in the connection test or elsewhere in the command's processing.
Reply to this answer
Add your answer
Answers are reviewed before publication.
8m~clipboard_471:
Worth running both commands with the same server and port values in the same session, so the results are easier to compare.