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?
-
2See also http://serverfault.com/questions/309357/ping-a-specific-port – Vadzim Sep 07 '15 at 11:00
13 Answers
Assuming that it's a TCP (rather than UDP) port that you're trying to use:
On the server itself, use
netstat -an
to check to see which ports are listening.From outside, just use
telnet host port
(ortelnet 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 Panel → Programs → Turn Windows Features on or off. In the list, scroll down and select Telnet Client and click OK.

- 30,738
- 21
- 105
- 131

- 334,560
- 70
- 407
- 495
-
319In Win7 or Vista defaul 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 Panel, Programs, and then Turn Windows Features on or off. In the list, scroll down and select Telnet Client and click OK – volody Nov 03 '10 at 01:41
-
-
12@PankajKohli use [PuTTy](http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html) telnet client instead. It does not need to be installed. – Colin Pickard May 12 '14 at 14:28
-
62What does `Could not open connection to the host, on port *x*: Connect failed` indicate? – Kenny Evitt Jul 08 '14 at 13:39
-
The proper syntax for mine is "telnet host port", if it connects your screen will go black or have some gibberish reply. – Ray Foss Jul 30 '14 at 11:49
-
2@Alnitak I just wanted to check as I think this already answers my question. When I do `telnet api-3t.sandbox.paypal.com 443` I get `Connecting to api-3t.sandbox.paypal.com...Could not open connection to the host on port 443: Connect failed` Is this because the firewall is blocking it? – Popeye Jan 21 '15 at 09:10
-
3there is a difference if you open telnet.exe and then type `o host port` vs open command line (cmd.exe) and then type `telnet host port` – Pawel Cioch Jul 21 '15 at 13:42
-
"connection timed out = firewall is blocking access" but whose firewall the source(outside pc) or the destination's( the PC i am tring to telnet) ? – avadhut007 Nov 11 '20 at 10:10
-
-
1@DmitrySurin UDP is way harder, and depends on whether the far end is configured to send ICMP "destination unreachable" messages, and on the near end process having sufficient privilege to be able to receive those. – Alnitak Nov 21 '20 at 09:17
On Windows you can use
netstat -na | findstr "your_port"
to narrow down the results. You can also filter for LISTENING
, ESTABLISHED
, TCP
and such. Mind it's case-sensitive though.
-
6you cant use find like this, it will be searching for files, you should use grep – Moataz Elmasry Sep 17 '13 at 13:53
-
43@MoatazElmasry, that's true on Linux, but this is on a Windows server, where find is the correct command. Grep is not available on Windows. I just ran the exact command mentioned here, and it worked perfectly. – Ben Wyatt Jan 30 '14 at 15:28
-
-
5When I used that command i.e netstat -an | find "19345" , I didnt get any result. what does it mean? – nanosoft Jul 22 '15 at 10:22
-
24`find` did not work in Windows 10 for me, but `netstat -na | findstr "8080"` worked – arun Mar 30 '16 at 20:18
-
8
-
This works on Windows 10 as well, they have brought piping and `find` to Windows – Hamman Samuel May 14 '16 at 12:26
-
1
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:
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).

- 16,941
- 11
- 79
- 125
-
4This is the best answer. Installing telnet isn't always straight-forward on other people's servers! – TrojanName Feb 25 '19 at 11:59
-
2
-
1This is a more reliable option than telnet, telnet would just hung not reporting anything while this reports that the port is available in my case. – axk Jan 03 '20 at 17:50
-
Great, for Windows 10 this is so far the best solution, without messing up installing third party extensions (on Linux I would have used telnet or nc). – Andrea Jun 16 '21 at 08:52
-
-
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.

- 30,738
- 21
- 105
- 131

- 12,262
- 10
- 69
- 70
-
When I used that command i.e netstat -an | find "19345" , I didnt get any result. what does it mean? – – nanosoft Jul 22 '15 at 10:29
-
2
-
1I get an error when I run `netstat -an | find "8080"` it says, `no such file named "8080"` – Pragyaditya Das Oct 11 '16 at 10:47
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

- 28,235
- 9
- 60
- 81

- 529
- 4
- 4
-
4
-
You could use this tool to check UDP port as well: `portqry -n 11.22.33.44 -p udp -e 19132` – HelloWorld101 May 25 '17 at 16:48
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.

- 30,738
- 21
- 105
- 131

- 2,982
- 6
- 38
- 64
-
Yes, but not for pasting Forth code, say, with [AmForth](http://amforth.sourceforge.net/) (unless using PuTTY in combination with [Edit Overflow](http://pmortensen.eu/)). – Peter Mortensen Aug 03 '19 at 16:14
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

- 30,738
- 21
- 105
- 131

- 397
- 3
- 5
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...

- 30,974
- 4
- 64
- 90

- 21,063
- 9
- 42
- 57
On Windows Server you can use
netstat -an | where{$_.Contains("Yourport")}

- 30,738
- 21
- 105
- 131

- 139
- 1
- 3
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.

- 30,738
- 21
- 105
- 131

- 1,200
- 1
- 12
- 25
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.

- 30,738
- 21
- 105
- 131

- 59
- 5