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
https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open
Last updated
Ask QuestionAsked 11 years, 10 months agoActive 3 years, 11 months agoViewed 556k times11638
What is a simple way in Windows to test if traffic gets through to a specific port on a remote machine?windowsnetworkingtcpipShareImprove this questionFollowedited Dec 9 '14 at 18:57Stan Kurdziel10544 bronze badgesasked Jul 2 '09 at 18:01Matt1,29344 gold badges1313 silver badges1616 bronze badges
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. "ShareImprove this answerFollowedited Jul 12 '12 at 6:41Steve Bennett5,1291212 gold badges4040 silver badges5757 bronze badgesanswered Jul 2 '09 at 18:30Peter M93688 silver badges1818 bronze badges
Note: Attempting to download this from Microsoft returned a page stating the download is "no longer available". – dgw Sep 16 '17 at 0:36
@dgw Thanks for that .. google shows a new version if you search for `portray" that I'll check out tomorrow – Peter M Sep 16 '17 at 2:27
2console version microsoft.com/downloads/… and ui version: download.microsoft.com/download/3/f/4/… Ref: support.microsoft.com/en-us/help/310099/… – Junior Mayhé Apr 13 '18 at 19:16
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.
2.Net method: $connection = (New-Object Net.Sockets.TcpClient).Connect($target,$port); If ($connection.Connected) { $connection.Close() }
– xXhRQ8sD2L7Z Dec 9 '14 at 23:09
On Win7, that doesn't work :-( – Jonesome Reinstate Monica Nov 5 '15 at 0:20
@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. – Iszi Nov 5 '15 at 14:38
1Seems to be Windows 8.1 - Can't seem to find it on Windows 8 – Andy Krouwel Dec 7 '15 at 10:16
2Works great on Windows 10, and I don't need to install any programs or add any features. Thanks! :) – Steve Bauman Jan 4 '18 at 16:52
Use the telnet command to connect to the server on the specified port, and see if a connection can be established.
Success:
Fail:
17doesn't work for UDP. – Adriano Varoli Piazza Jul 2 '09 at 20:23
9UDP is connectionless.. – Amalgovinus Jun 23 '14 at 18:46
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
13Question asks about open ports on a remote machine, not local. – Chris S Jun 26 '13 at 13:04
Use netcat Windows port:
3Local machine yes, remote machine no. – Joe Jul 2 '09 at 18:04
3This answer was posted before the edit that specified that it's about a port on remote machine. – quosoo Jul 2 '09 at 18:11
Add a commentHighly active question. Earn 10 reputation in order to answer this question. The reputation requirement helps protect this question from spam and non-answer activity.
If you're not averse to using third-party utilities, Nmap is also a very good friend to have and it works from the command line.ShareImprove this answerFollowedited May 25 '17 at 16:19answered Oct 16 '14 at 6:18Iszi1,76677 gold badges2222 silver badges3333 bronze badges
ShareImprove this answerFollowanswered Jul 2 '09 at 18:05Jørn Schou-Rode67011 gold badge66 silver badges1212 bronze badges
Netcat is a better tool for these sorts of things, including UDP, watch out though, some AV softwares consider it an 'evil hacker tool'ShareImprove this answerFollowanswered Jul 2 '09 at 18:07whatsisname28111 gold badge33 silver badges77 bronze badgesAdd a comment1
Netstat documentation on microsoft.comShareImprove this answerFollowanswered Jul 11 '12 at 13:05Baldy18722 silver badges1111 bronze badges
ShareImprove this answerFollowanswered Oct 25 '16 at 12:48rustyx1,17722 gold badges1414 silver badges2525 bronze badgesAdd a comment-2
'netstat' is you friend.ShareImprove this answerFollowanswered Jul 2 '09 at 18:03quosoo10511 bronze badge