Portqry is a command-line utility that you can use to help troubleshoot TCP/IP connectivity issues, which you can run on Windows 2000 and Windows XP. The utility reports the port status of target Transition Control Protocol (TCP) and User Datagram Protocol (UDP) ports on a remote computer.

You can also use Portqry in the following ways:

  • To troubleshoot Active Directory issues in which you have to verify basic TCP/IP connectivity, which can be especially useful in environments with firewalls.
  • To verify connectivity to TCP/IP ports that are used by Active Directory for Lightweight Directory Access Protocol (LDAP), remote procedure call (RPC), and Domain Name Service (DNS).

Portqry reports the status of a port in one of three ways:

  • Listening: A process is listening on the target port on the target system. Portqry received a response from the port.
  • Not Listening: No process is listening on the target port on the target system. Portqry received an Internet Control Message Protocol (ICMP) “Destination Unreachable – Port Unreachable” message back from the target UDP port. Or, if the target port is a TCP port, Portqry received a TCP acknowledgement packet with the Reset flag set.
  • Filtered: The target port on the target system is being filtered. Portqry did not receive a response from the target port. A process may or may not be listening on the port. By default, TCP ports are queried three times and UDP ports are queried once before reporting the target port is filtered.

With Portqry, you can also query an LDAP service. It knows how to send an LDAP query (by using UDP and TCP) and interpret an LDAP server’s response to the query. The response from the LDAP server is parsed, formatted and returned to the user.


When you run the following command:portqry -n myserver -p udp -e 389Portqry automatically resolves UDP port 389 using the %SystemRoot%\System32\Drivers\…\Services file that every Windows 2000 and Windows XP system has by default. If it resolves the port to the LDAP service, it sends an unformatted user datagram to UDP port 389 on the target system. Portqry will not receive a response from the port as the LDAP service only responds to a properly formatted LDAP query. Portqry will report that the port is listening or filtered. Portqry will then send a properly formatted LDAP query to UDP port 389. If it receives a response to the query, it returns the entire response to the user and report that the port is listening. If portqry does not receive a response to the query, it reports that the port is filtered.

Sample Output

C:\>portqry -n mydc.reskit.com -e 389 -p udp 

Querying target system called: 


Attempting to resolve name to IP address... 

Name resolved to 

UDP port 389 (unknown service): LISTENING or FILTERED 

Sending LDAP query to UDP port 389... 

LDAP query response: 

currentdate: 10/11/2001 23:10:21 (unadjusted GMT) 
dsServiceName: CN=NTDS  
namingContexts: DC=reskit,DC=com 
defaultNamingContext: DC=reskit,DC=com 
rootDomainNamingContext: DC=reskit,DC=com 
supportedControl: 1.2.840.113556.1.4.319 
supportedLDAPVersion: 3 
supportedLDAPPolicies: MaxPoolThreads 
highestCommittedUSN: 815431405 
supportedSASLMechanisms: GSSAPI 
dnsHostName: MYDC.reskit.com 
ldapServiceName: reskit.com:mydc$@RESKIT.COM 
supportedCapabilities: 1.2.840.113556.1.4.800 
isSynchronized: TRUE 
isGlobalCatalogReady: TRUE 

======== End of LDAP query response ======== 
UDP port 389 is LISTENING

In this sample, port 389 is listening and from the output it can be determined which LDAP service is listening on the port and some details about its configuration. This information may also be useful in troubleshooting various problems.

Post By Gishore J Kallarackal (2,121 Posts)

Gishore J Kallarackal is the founder of techgurulive. The purpose of this site is to share information about free resources that techies can use for reference. You can follow me on the social web, subscribe to the RSS Feed or sign up for the email newsletter for your daily dose of tech tips & tutorials. You can content me via @twitter or e-mail.

Website: → Techgurulive