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

## [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 Question](https://serverfault.com/questions/ask)Asked 11 years, 10 months agoActive [3 years, 11 months ago](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open?lastactivity)Viewed 556k times11638

What is a simple way in Windows to test if traffic gets through to a specific port on a remote machine?[windows](https://serverfault.com/questions/tagged/windows)[networking](https://serverfault.com/questions/tagged/networking)[tcpip](https://serverfault.com/questions/tagged/tcpip)[Share](https://serverfault.com/q/35218)[Improve this question](https://serverfault.com/posts/35218/edit)Follow[edited Dec 9 '14 at 18:57](https://serverfault.com/posts/35218/revisions)[![](https://www.gravatar.com/avatar/49a9e732bedf2a7a022255eceb470e19?s=32\&d=identicon\&r=PG)](https://serverfault.com/users/167332/stan-kurdziel)[Stan Kurdziel](https://serverfault.com/users/167332/stan-kurdziel)10544 bronze badgesasked Jul 2 '09 at 18:01[![](https://www.gravatar.com/avatar/e30f1d60c40c34f9395538cc52930281?s=32\&d=identicon\&r=PG)](https://serverfault.com/users/11384/matt)[Matt](https://serverfault.com/users/11384/matt)1,29344 gold badges1313 silver badges1616 bronze badges

* Related: [superuser.com/questions/11207/…](http://superuser.com/questions/11207/how-can-i-see-all-active-connections) – [Pacerier](https://serverfault.com/users/87017/pacerier) [Feb 23 '15 at 11:00](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open#comment820093_35218)&#x20;

[Add a comment](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open#)

### 7 Answers

[Active](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open?answertab=active#tab-top)[Oldest](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open?answertab=oldest#tab-top)[Votes](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open?answertab=votes#tab-top)75

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

[Portqry.exe](http://support.microsoft.com/kb/310099)

*"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. "*[Share](https://serverfault.com/a/35225)[Improve this answer](https://serverfault.com/posts/35225/edit)Follow[edited Jul 12 '12 at 6:41](https://serverfault.com/posts/35225/revisions)[![](https://www.gravatar.com/avatar/75f5707160697b2164444fc3f5054084?s=32\&d=identicon\&r=PG)](https://serverfault.com/users/68259/steve-bennett)[Steve Bennett](https://serverfault.com/users/68259/steve-bennett)5,1291212 gold badges4040 silver badges5757 bronze badgesanswered Jul 2 '09 at 18:30[![](https://www.gravatar.com/avatar/c04ab8ca94ce77e57e44ecac3b329b38?s=32\&d=identicon\&r=PG\&f=1)](https://serverfault.com/users/12255/peter-m)[Peter M](https://serverfault.com/users/12255/peter-m)93688 silver badges1818 bronze badges

* Note: Attempting to download this from Microsoft returned a page stating the download is "no longer available". – [dgw](https://serverfault.com/users/13440/dgw) [Sep 16 '17 at 0:36](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open#comment1124982_35225)
* @dgw Thanks for that .. google shows a new version if you search for \`portray" that I'll check out tomorrow – [Peter M](https://serverfault.com/users/12255/peter-m) [Sep 16 '17 at 2:27](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open#comment1124990_35225)
* 2console version [microsoft.com/downloads/…](http://www.microsoft.com/downloads/details.aspx?familyid=89811747-c74b-4638-a2d5-ac828bdc6983\&displaylang=en) and ui version: [download.microsoft.com/download/3/f/4/…](http://download.microsoft.com/download/3/f/4/3f4c6a54-65f0-4164-bdec-a3411ba24d3a/portqryui.exe) Ref: [support.microsoft.com/en-us/help/310099/…](https://support.microsoft.com/en-us/help/310099/description-of-the-portqry-exe-command-line-utility) – [Junior Mayhé](https://serverfault.com/users/24029/junior-mayh%c3%a9) [Apr 13 '18 at 19:16](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open#comment1174359_35225)&#x20;

[Add a comment](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open#)90

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, [Nmap](http://nmap.org/) is also a very good friend to have and it works from the command line.[Share](https://serverfault.com/a/637396)[Improve this answer](https://serverfault.com/posts/637396/edit)Follow[edited May 25 '17 at 16:19](https://serverfault.com/posts/637396/revisions)answered Oct 16 '14 at 6:18[![](https://www.gravatar.com/avatar/8f8571493d71202986f2a6ab0dbd7c23?s=32\&d=identicon\&r=PG)](https://serverfault.com/users/54923/iszi)[Iszi](https://serverfault.com/users/54923/iszi)1,76677 gold badges2222 silver badges3333 bronze badges

* 2.Net method: `$connection = (New-Object Net.Sockets.TcpClient).Connect($target,$port); If ($connection.Connected) { $connection.Close() }` – [xXhRQ8sD2L7Z](https://serverfault.com/users/71955/xxhrq8sd2l7z) [Dec 9 '14 at 23:09](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open#comment789173_637396)
* On Win7, that doesn't work :-( – [Jonesome Reinstate Monica](https://serverfault.com/users/13716/jonesome-reinstate-monica) [Nov 5 '15 at 0:20](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open#comment915685_637396)
* @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](https://serverfault.com/users/54923/iszi) [Nov 5 '15 at 14:38](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open#comment915918_637396)&#x20;
* 1Seems to be Windows 8.1 - Can't seem to find it on Windows 8 – [Andy Krouwel](https://serverfault.com/users/325908/andy-krouwel) [Dec 7 '15 at 10:16](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open#comment927145_637396)
* 2Works great on Windows 10, and I don't need to install any programs or add any features. Thanks! :) – [Steve Bauman](https://serverfault.com/users/334426/steve-bauman) [Jan 4 '18 at 16:52](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open#comment1149715_637396)

[Add a comment](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open#)25

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

**Success:**

```
$ telnet my_server 25
220 my_server ESMTP Postfix
```

**Fail:**

```
$ telnet my_server 23632
Connecting To my_server...Could not open connection to the host, on port 23632:
Connect failed
```

[Share](https://serverfault.com/a/35223)[Improve this answer](https://serverfault.com/posts/35223/edit)Followanswered Jul 2 '09 at 18:05[![](https://www.gravatar.com/avatar/967f06926c0286ce01564d0e772d71c2?s=32\&d=identicon\&r=PG)](https://serverfault.com/users/12695/j%c3%b8rn-schou-rode)[Jørn Schou-Rode](https://serverfault.com/users/12695/j%c3%b8rn-schou-rode)67011 gold badge66 silver badges1212 bronze badges

* 17doesn't work for UDP. – [Adriano Varoli Piazza](https://serverfault.com/users/904/adriano-varoli-piazza) [Jul 2 '09 at 20:23](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open#comment26601_35223)
* 9UDP is connectionless.. – [Amalgovinus](https://serverfault.com/users/226993/amalgovinus) [Jun 23 '14 at 18:46](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open#comment722654_35223)

[Add a comment](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open#)7

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'[Share](https://serverfault.com/a/35224)[Improve this answer](https://serverfault.com/posts/35224/edit)Followanswered Jul 2 '09 at 18:07[![](https://i.stack.imgur.com/B3RDi.png?s=32\&g=1)](https://serverfault.com/users/47231/whatsisname)[whatsisname](https://serverfault.com/users/47231/whatsisname)28111 gold badge33 silver badges77 bronze badges[Add a comment](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open#)1

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

```
netstat -a
```

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

[Netstat documentation on microsoft.com](https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/netstat.mspx?mfr=true)[Share](https://serverfault.com/a/406744)[Improve this answer](https://serverfault.com/posts/406744/edit)Followanswered Jul 11 '12 at 13:05[![](https://www.gravatar.com/avatar/ec9e61562949e6c0a5251fe3387a070b?s=32\&d=identicon\&r=PG)](https://serverfault.com/users/57439/baldy)[Baldy](https://serverfault.com/users/57439/baldy)18722 silver badges1111 bronze badges

* 13Question asks about open ports on a remote machine, not local. – [Chris S](https://serverfault.com/users/33417/chris-s) [Jun 26 '13 at 13:04](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open#comment588543_406744)

[Add a comment](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open#)0

Use [**netcat Windows port**](https://eternallybored.org/misc/netcat/):

```
>nc -zvv www.google.com 80
www.google.com [108.177.96.103] 80 (http) open
sent 0, rcvd 0
>

>nc -zvv www.google.com 888
www.google.com [108.177.96.147] 888 (?): TIMEDOUT
sent 0, rcvd 0: NOTSOCK
>
```

[Share](https://serverfault.com/a/811163)[Improve this answer](https://serverfault.com/posts/811163/edit)Followanswered Oct 25 '16 at 12:48[![](https://www.gravatar.com/avatar/e18b024a122df74275dd2c4486e8a2b4?s=32\&d=identicon\&r=PG)](https://serverfault.com/users/62843/rustyx)[rustyx](https://serverfault.com/users/62843/rustyx)1,17722 gold badges1414 silver badges2525 bronze badges[Add a comment](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open#)-2

'netstat' is you friend.[Share](https://serverfault.com/a/35219)[Improve this answer](https://serverfault.com/posts/35219/edit)Followanswered Jul 2 '09 at 18:03[![](https://www.gravatar.com/avatar/1058fe2c355b79d69928d8ae7b8b9afb?s=32\&d=identicon\&r=PG)](https://serverfault.com/users/22018/quosoo)[quosoo](https://serverfault.com/users/22018/quosoo)10511 bronze badge

* 3Local machine yes, remote machine no. – Joe [Jul 2 '09 at 18:04](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open#comment26542_35219)
* 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](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open#comment26543_35219)

[Add a comment](https://serverfault.com/questions/35218/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open#)[**Highly active question**](https://serverfault.com/help/privileges/protect-questions). 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 [windows](https://serverfault.com/questions/tagged/windows) [networking](https://serverfault.com/questions/tagged/networking) [tcpip](https://serverfault.com/questions/tagged/tcpip) or [ask your own question](https://serverfault.com/questions/ask).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learnimportant.gitbook.io/learn-important/windows10/in-windows-using-the-command-line-how-do-you-check-if-a-remote-port-is-open.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
