DEV Community

Victor James
Victor James

Posted on • Originally published at on

PORTQRY Command: Displays the Status of Ports and Services -RTP



The PORTQRY windows command-line tool displays the status of ports and services. Let’s see about this windows command with the syntax below.

CMD Line

CMD Line is a text-based interface that transfers the command from the user to the OS.

CLI-Command Line Interpreter

The command-line interpreter (CLI) for windows is CMD.EXE. Also, you can use PowerShell, which can automate many system administration tasks and these tasks are not approachable in command prompt. With the help of the CLI, you can communicate with your system by typing the text in commands. As a result, your system answers to the text that you have entered previously, and then the user can proceed with the next command line that shows up.

To open the Run command Window

Run command window helps you to run programs, open the files and folders. And there are several ways to open up the run command dialog box. This run command box is useful for you to head straight to the destined program easily.

By using the Keyboard shortcut Key:


The shortcut key method to the run command box is the most commonly used one. Also, this method is in all versions of Windows. It would help if you pressed the Windows+ R ** ** key concurrently to open the Run command dialog box.

Run command box
Run command box

What does the PORTQRY windows command do?

The PORTQRY ** windows command-line tool is for **displaying the status of ports and services. This command-line tool is to help you to troubleshoot TCP/IP connectivity issues. And this command displays the current status of ** TCP** and UDP ports. It points out the ** security** , returns ** LDAP base query info** , SMTP , POP3 , IMAP4 status , enumerates ** SQL ** Server instances, ** Local ports** , local services running.

The PORTQRY command can question a single port , ** multiple ports** , and a sequential range of ports.

Command-line mode


portqry -n name_to_query [-p protocol]
             [-e | -r | -o endpoint(s)]
                [other options]

Enter fullscreen mode Exit fullscreen mode

Available Options

  • -n [name_to_query]– Indicates the ** IP address** or name of the system to query.
  • -p [protocol]– Specifies the TCP or UDP or both, and the default is TCP.
  • -e [endpoint]– Indicates the single Port to query , valid range: 1-65535.
  • -r [end point range]– Specifies the range of ports to query.
  • -o [end point order]– Indicates a range of ports to query in an order.
  • -l [logfile]Outputs a log file.
  • -y – This option *overwrites the existing log file * without prompting.
  • -sp – Specifies the *initial source port * to use for the query.
  • -sl – ‘ slow link delay ‘ Wait longer for UDP replies from remote systems.
  • -nr – By-pass default IP address-to-name resolution ignored unless an IP address is specified after -n.
  • -cn – Specify SNMP community name for query ignored unless querying an SNMP port
  • must be delimited with !.
  • -q – ‘Quiet’ operation runs with no output.
    • returns 0 if Port is listening.
    • returns 1 if Port is not listening.
    • returns2 if Port is listening or filtered.

Local Mode


   portqry -local [-wt seconds] [-l logfile] [-v]
   portqry -wpid pid [-wt seconds] [-l logfile] [-v]
   portqry -wport port [-wt seconds] [-l logfile] [-v]

Enter fullscreen mode Exit fullscreen mode


  • -local – Identifies local port usage , port to process mapping, service port usage, and list of loaded modules
  • -wport [port_number]– Observes the specified port and reports when the port’s connection status changes.
  • -wpid [process_ID]– Observes the specified process ID (PID) and reports when the PID’s connection status changes.
  • -wt [seconds]– Watches time option and specify how often to check for status changes, valid range: 1 – 1200 seconds, default = 60 secs.
  • -l [logfile]– Log file to create.
  • -vVerbose output.

The Local mode gives elaborate data on the Local system’s ports.

Interactive Mode


portqry -i [-options]

Enter fullscreen mode Exit fullscreen mode

If you want help with -i , you can type ‘ help ‘ and press enter.


We hope through this guide you get to know about the PORTQRY command. For more windows commands with examples and syntax, check out our website. Also, we have listed some recently posted articles which might be useful too.

Related Articles

The post PORTQRY Command: Displays the Status of Ports and Services -RTP appeared first on Windows Commands- SS64 Commands.

Discussion (0)