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
Last updated
Was this helpful?
https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open
Last updated
Was this helpful?
Asked 11 years, 10 months agoActive Viewed 556k times11638
What is a simple way in Windows to test if traffic gets through to a specific port on a remote machine?Follow10544 bronze badgesasked Jul 2 '09 at 18:011,29344 gold badges1313 silver badges1616 bronze badges
Related: –
75
I found a hiddem gem the other day from Microsoft that is designed for testing ports:
"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. "Follow5,1291212 gold badges4040 silver badges5757 bronze badgesanswered Jul 2 '09 at 18:3093688 silver badges1818 bronze badges
Note: Attempting to download this from Microsoft returned a page stating the download is "no longer available". –
@dgw Thanks for that .. google shows a new version if you search for `portray" that I'll check out tomorrow –
2console version and ui version: Ref: –
90
Which version of Windows? For Windows 8/Server 2012 and later, the following works in PowerShell:
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.
Use the telnet command to connect to the server on the specified port, and see if a connection can be established.
Success:
Fail:
Telnet will work for TCP.
the following command will list all ports in use on the machine...
The output contains the protocol, local address, foreign address and current state
If you're not averse to using third-party utilities, is also a very good friend to have and it works from the command line.Followanswered Oct 16 '14 at 6:181,76677 gold badges2222 silver badges3333 bronze badges
2.Net method: $connection = (New-Object Net.Sockets.TcpClient).Connect($target,$port); If ($connection.Connected) { $connection.Close() }
–
On Win7, that doesn't work :-( –
@samsmith Are you talking about the command in my answer, or the one ST8Z...'s comment? The one in my answer only works for Win8/2k12 and higher, and the answer says as much. –
1Seems to be Windows 8.1 - Can't seem to find it on Windows 8 –
2Works great on Windows 10, and I don't need to install any programs or add any features. Thanks! :) –
25
Followanswered Jul 2 '09 at 18:0567011 gold badge66 silver badges1212 bronze badges
17doesn't work for UDP. –
9UDP is connectionless.. –
7
Netcat is a better tool for these sorts of things, including UDP, watch out though, some AV softwares consider it an 'evil hacker tool'Followanswered Jul 2 '09 at 18:0728111 gold badge33 silver badges77 bronze badges1
Followanswered Jul 11 '12 at 13:0518722 silver badges1111 bronze badges
13Question asks about open ports on a remote machine, not local. –
0
Use :
Followanswered Oct 25 '16 at 12:481,17722 gold badges1414 silver badges2525 bronze badges-2
'netstat' is you friend.Followanswered Jul 2 '09 at 18:0310511 bronze badge
3Local machine yes, remote machine no. – Joe
3This answer was posted before the edit that specified that it's about a port on remote machine. – quosoo
. Earn 10 reputation in order to answer this question. The reputation requirement helps protect this question from spam and non-answer activity.