In Windows, using the command line, how do you check if a remote port is open?

https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open

Ask Questionarrow-up-rightAsked 11 years, 10 months agoActive 3 years, 11 months agoarrow-up-rightViewed 556k times11638

What is a simple way in Windows to test if traffic gets through to a specific port on a remote machine?windowsarrow-up-rightnetworkingarrow-up-righttcpiparrow-up-rightSharearrow-up-rightImprove this questionarrow-up-rightFollowedited Dec 9 '14 at 18:57arrow-up-rightarrow-up-rightStan Kurdzielarrow-up-right10544 bronze badgesasked Jul 2 '09 at 18:01arrow-up-rightMattarrow-up-right1,29344 gold badges1313 silver badges1616 bronze badges

Add a commentarrow-up-right

7 Answers

Activearrow-up-rightOldestarrow-up-rightVotesarrow-up-right75

I found a hiddem gem the other day from Microsoft that is designed for testing ports:

Portqry.exearrow-up-right

"Portqry.exe is a command-line utility that you can use to help troubleshoot TCP/IP connectivity issues. Portqry.exe runs on Windows 2000-based computers, on Windows XP-based computers, and on Windows Server 2003-based computers. The utility reports the port status of TCP and UDP ports on a computer that you select. "Sharearrow-up-rightImprove this answerarrow-up-rightFollowedited Jul 12 '12 at 6:41arrow-up-rightarrow-up-rightSteve Bennettarrow-up-right5,1291212 gold badges4040 silver badges5757 bronze badgesanswered Jul 2 '09 at 18:30arrow-up-rightPeter Marrow-up-right93688 silver badges1818 bronze badges

Add a commentarrow-up-right90

Which version of Windows? For Windows 8/Server 2012 and later, the following works in PowerShell:

Test-NetConnection 128.159.1.1 -Port 80

Some Googling will also turn up alternatives which use the .NET Framework directly (since PowerShell lets you do that) for systems running lower versions of Windows that won't have Test-NetConnection available.

If you're not averse to using third-party utilities, Nmaparrow-up-right is also a very good friend to have and it works from the command line.Sharearrow-up-rightImprove this answerarrow-up-rightFollowedited May 25 '17 at 16:19arrow-up-rightanswered Oct 16 '14 at 6:18arrow-up-rightIsziarrow-up-right1,76677 gold badges2222 silver badges3333 bronze badges

Add a commentarrow-up-right25

Use the telnet command to connect to the server on the specified port, and see if a connection can be established.

Success:

Fail:

Sharearrow-up-rightImprove this answerarrow-up-rightFollowanswered Jul 2 '09 at 18:05arrow-up-rightJørn Schou-Rodearrow-up-right67011 gold badge66 silver badges1212 bronze badges

Add a commentarrow-up-right7

Telnet will work for TCP.

Netcat is a better tool for these sorts of things, including UDP, watch out though, some AV softwares consider it an 'evil hacker tool'Sharearrow-up-rightImprove this answerarrow-up-rightFollowanswered Jul 2 '09 at 18:07arrow-up-rightwhatsisnamearrow-up-right28111 gold badge33 silver badges77 bronze badgesAdd a commentarrow-up-right1

the following command will list all ports in use on the machine...

The output contains the protocol, local address, foreign address and current state

Netstat documentation on microsoft.comarrow-up-rightSharearrow-up-rightImprove this answerarrow-up-rightFollowanswered Jul 11 '12 at 13:05arrow-up-rightBaldyarrow-up-right18722 silver badges1111 bronze badges

Add a commentarrow-up-right0

Use netcat Windows portarrow-up-right:

Sharearrow-up-rightImprove this answerarrow-up-rightFollowanswered Oct 25 '16 at 12:48arrow-up-rightrustyxarrow-up-right1,17722 gold badges1414 silver badges2525 bronze badgesAdd a commentarrow-up-right-2

'netstat' is you friend.Sharearrow-up-rightImprove this answerarrow-up-rightFollowanswered Jul 2 '09 at 18:03arrow-up-rightquosooarrow-up-right10511 bronze badge

Add a commentarrow-up-rightHighly active questionarrow-up-right. Earn 10 reputation in order to answer this question. The reputation requirement helps protect this question from spam and non-answer activity.

Not the answer you're looking for? Browse other questions tagged windowsarrow-up-right networkingarrow-up-right tcpiparrow-up-right or ask your own questionarrow-up-right.

Last updated