LKBEN10665: Howto know a certain port is open, used and listening on a windows system


Symptom

You need to connect to a certain server and port but you are not shure the server is listening

Cause

You can use this test to make shure the server is listening

Solution

Windows has a very nice port query command. (portqry) Portqry enables you to test a port and its status.

portqry -n lubbysrv -p tcp -e 135
Querying target system called:
lubbysrv
Attempting to resolve name to IP address...
Name resolved to 192.168.123.13
TCP port 135 (epmap service): LISTENING
Querying Endpoint Mapper Database...
Server’s response:

UUID: a4f1db00-ca47-1067-b31f-00dd010662da
Exchange 2003 Server STORE EMSMDB Interface
ncacn_http:192.168.123.6[6001]

Here are a few more examples:

portqry -n myserver.com -e 25
portqry -n 10.0.0.1 -e 53 -p UDP -i
portqry -n host1.dev.reskit.com -r 21:445
portqry -n 10.0.0.1 -o 25,445,1024 -p both


portqry -n lubbyex1 -e 25

Querying target system called:
lubby1-ex1

Attempting to resolve name to IP address...

Name resolved to 192.168.123.40

TCP port 25 (smtp service): LISTENING

Data returned from port:
220 lubby1-ex1.lubby.test Microsoft ESMTP MAIL Service, Version: 6.0.3790.3959
ready at  Mon, 17 Mar 2008 16:03:30 +0100


portqry -n TSE01 -e 1494

Querying target system called:

 TSE01

Attempting to resolve name to IP address...

Name resolved to 192.168.123.100


TCP port 1494 (unknown service): LISTENING

Here we check if RDP is active:

portqry -n DC01 -e 3389

Querying target system called:

 DC01

Attempting to resolve name to IP address...

Name resolved to 192.168.123.10


TCP port 3389 (sapgw89 service): LISTENING

Disclaimer:

The information provided in this document is intended for your information only. Lubby makes no claims to the validity of this information. Use of this information is at own risk!

About the Author

Author: Wim Peeters - Keskon GmbH & Co. KG

Wim Peeters is electronics engineer with an additional master in IT and over 30 years of experience, including time spent in support, development, consulting, training and database administration. Wim has worked with SQL Server since version 6.5. He has developed in C/C++, Java and C# on Windows and Linux. He writes knowledge base articles to solve IT problems and publishes them on the Lubby Knowledge Platform.