How do I determine if a port is open on a Windows server?

Windows Server-2003PortPing

Windows Server-2003 Problem Overview


I'm trying to install a site under an alternative port on a server, but the port may be closed by a firewall. Is there a way to ping out or in, on a specific port, to see if it is open?

Windows Server-2003 Solutions


Solution 1 - Windows Server-2003

Assuming that it's a TCP (rather than UDP) port that you're trying to use:

  1. On the server itself, use netstat -an to check to see which ports are listening.

  2. From outside, just use telnet host port (or telnet host:port on Unix systems) to see if the connection is refused, accepted, or timeouts.

On that latter test, then in general:

  • connection refused means that nothing is running on that port
  • accepted means that something is running on that port
  • timeout means that a firewall is blocking access

On Windows 7 or Windows Vista the default option 'telnet' is not recognized as an internal or external command, operable program or batch file. To solve this, just enable it: Click Start* → Control PanelProgramsTurn Windows Features on or off. In the list, scroll down and select Telnet Client and click OK.

Solution 2 - Windows Server-2003

On Windows you can use

netstat -na | find "your_port"

to narrow down the results. You can also filter for LISTENING, ESTABLISHED, TCP and such. Mind it's case-sensitive though.

Solution 3 - Windows Server-2003

If you're checking from the outside, not from the server itself, and you don't want to bother installing telnet (as it doesn't come with the last versions of Windows) or any other software, then you have native PowerShell:

Test-NetConnection -Port 800 -ComputerName 192.168.0.1 -InformationLevel Detailed

(Unfortunately this only works with PowerShell 4.0 or newer. To check your PowerShell version, type $PSVersionTable.)

PS: Note, these days there are some claims on the twittersphere that hint that this answer could be improved by mentioning "Test-Connection" from PowerShell Core, or the shortcut "tnc". See https://twitter.com/david_obrien/status/1214082339203993600 and help me edit this answer to improve it please!


(If you have a PSVersion < 4.0, you're out of luck. Check this table:

Enter image description here

Even though you can upgrade your version of PowerShell by installing the Windows Management Framework 4.0, it didn't do the trick for me, Test-NetConnection cmdlet is still not available).

Solution 4 - Windows Server-2003

I did like that:

netstat -an | find "8080" 

from telnet

telnet 192.168.100.132 8080

And just make sure that the firewall is off on that machine.

Solution 5 - Windows Server-2003

On a Windows machine you can use PortQry from Microsoft to check whether an application is already listening on a specific port using the following command:

portqry -n 11.22.33.44 -p tcp -e 80

Solution 6 - Windows Server-2003

If telnet is not available, download PuTTY. It is a far superior Telnet, SSH, etc. client and will be useful in many situations, not just this one, especially if you are administering a server.

Solution 7 - Windows Server-2003

Use this if you want to see all the used and listening ports on a Windows server:

netstat -an |find /i "listening"

See all open, listening, established ports:

netstat -a

Solution 8 - Windows Server-2003

Do you want a tool for doing it? There is a website at http://www.canyouseeme.org/. Otherwise, you need some other server to call you back to see if a port is open...

Solution 9 - Windows Server-2003

On Windows Server you can use

netstat -an | where{$_.Contains("Yourport")}

Solution 10 - Windows Server-2003

PsPing from Sysinternals is also very good.

Solution 11 - Windows Server-2003

Another option is tcping.

For example:

tcping host port

Solution 12 - Windows Server-2003

Here is what worked for me:

  • Open a command prompt
  • Type telnet
  • Microsoft Telnet>open <host name or IP address><space><port>

It will confirm whether the port is opened.

Solution 13 - Windows Server-2003

Another utility that I found and is good and small as well, is PortQry Command Line Port Scanner version 2.0.

You can ping a server and a port and it will tell you the state of the port. There is a command-line utility and a UI for it.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJasonView Question on Stackoverflow
Solution 1 - Windows Server-2003AlnitakView Answer on Stackoverflow
Solution 2 - Windows Server-2003J.CelmerView Answer on Stackoverflow
Solution 3 - Windows Server-2003knocteView Answer on Stackoverflow
Solution 4 - Windows Server-2003nsvView Answer on Stackoverflow
Solution 5 - Windows Server-2003Gunjan MogheView Answer on Stackoverflow
Solution 6 - Windows Server-2003MachtynView Answer on Stackoverflow
Solution 7 - Windows Server-2003zehnaseebView Answer on Stackoverflow
Solution 8 - Windows Server-2003Douglas MayleView Answer on Stackoverflow
Solution 9 - Windows Server-2003DerbiumView Answer on Stackoverflow
Solution 10 - Windows Server-2003user1767635View Answer on Stackoverflow
Solution 11 - Windows Server-2003VadzimView Answer on Stackoverflow
Solution 12 - Windows Server-2003Praveen TiwariView Answer on Stackoverflow
Solution 13 - Windows Server-2003GilbertoView Answer on Stackoverflow