Using the command line to check if port is open.

In this article regarding command line to check if port is open. We are going to show you some of the command line you can use for that.

We are going to talk about the following command line tools:

  • Netstat
  • Telnet
  • PowerShell

All the above tools can be found on your windows device. To use them you need to open the command line.

This can be done by one of the following ways:

  • Press the Windows button + R. Type cmd and press enter.
  • Press the Windows button or press start and type cmd, you should see the ‘command prompt’ press on it and the command line will be open.

The command line to check if port is open:

Netstat:

From the command line type ‘netstat -an’ this will show you a list of open port on your system.

You will see a list of status for some of the ports.

  • LISTENING – This port is waiting for incoming connections.
  • ESTABLISHED – This port is connected to a remote device.
  • CLOSE_WAIT – This port is closing the current connection.

With the netstat command line tool you can check what are the current local open port and their status.

Telnet:

With the telnet command line, you can check if a remote port is open.

Just try the following:

telnet [REMOTE HOST] [PORT]

Example:

telnet openport.net 443

This command will try to connect to openport.net using port 443 that also known as HTTPS.

If you try to run the command you will see a blank screen, which means the port is open.

PowerShell:

To open PowerShell you can press on start and start typing Powershell.

You might need to right-click on it and select run as administrator.

Type in the following commands:

$targetServer="REMOTE HOST";

$targetPort="PORT TO CHECK";

echo ((new-object Net.Sockets.TcpClient).Connect($targetServer,$targetPort)) "$targetPort is

open on $targetServer.";

This will output the status of the selected port. If you use the local address (localhost or 127.0.0.1) you can use this to check if local port is open.

Conclusion:

In this post, we talk about 3 tools that you can use to check the local and remote port status from the command line. I hope it helps you to get your answer.

Please share it with your friends.

 

 

1 thought on “Using the command line to check if port is open.”

  1. Pingback: URL

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.