Windows OS

How to Check If a Port is Open or Closed on a Windows Service

Open ports are the types of ports that are configured to accept packets and are necessary to communicate across the network. In contrast, closed ports cannot establish connections to a network rejecting the packets. Remember that it is necessary to close unused ports to restrict access to any service running on the system without the user’s awareness.

In this post, we will check out the methods to find if a port is open or closed on a Windows service:

Let’s get started!

Method 1: Check If a Port is Open or Closed on a Windows Service Using Telnet

To check if a port is open or closed on a Windows Service using Telnet, follow the below-given procedure.

Step 1: Enable Telnet on Windows

To enable Telnet on Windows, first open the “Turn Windows features on or off” Control panel setting. For this purpose, search for “Windows Features” in the “Startup” menu and open it:

From the “Window Features” wizard, mark the “Telnet Client” checkbox and hit the “OK” button:

Upon doing so, the Telnet will be enabled on Windows. Then, press the “Close” button:

Step 2: Open Command Prompt

Run the Windows Command Prompt as an administrator using the “Startup” menu:

Step 3: Check Port Status Using telnet Command

Use the “telnet” command and specify the hostname and port number to check if a port is open or closed on Windows service:

>telnet www.google.com 443

If the output opens “Telnet <hostname>” command prompt window and show only a blinking cursor, it means that the port is open and being used:

If the output displays the message “Could not open a connection to the host”, it indicates that the specified port is closed:

Let’s move forward to check out the second approach used to find out if a Windows port status.

Method 2: Check If a Port is Open or Closed on a Windows Service Using netstat

Running the “netstat” command will also let you know if a port is open or closed on a Windows Service. This command is utilized as a monitoring tool for the network connections.

To understand the usage of the “netstat” command, take a look at the below-mentioned examples.

Example 1: List Down all Port States

The “-netstat” command with the “-a” option will show all the open, listening, and established ports on the command prompt, along with the other details:

>netstat -a

Example 2: Check out a Specific Port State

To check out if a port is open or close, execute the “netstat” command and pipe out its output to the “findstr” command using the pipe operator “|”. The “findstr” command will search for the specified port number and display the resultant related info:

>netstat -na | findstr "58613"

Example 3: Check out If Ports are Currently Open or Closed Along With PID

Utilize the below provided command to check out ports that are currently open on Windows along with their Process ID (PID), State, Local Address, Foreign Address, and a Protocol used by a port.

>netstat -aon

The port is open if it shows “LISTENING” in the port state:

Let’s move ahead toward the third approach to check if the port is open or closed on a Window service.

Method 3: Check If a Port is Open or Closed on a Windows Service Using PowerShell

To check out if a port is open or closed on a Windows service using PowerShell, follow up the below-given procedure.

Step 1: Open PowerShell

Firstly, press “Window+X” to view the Power User panel. Then, select and open the “Windows PowerShell (Admin)” option:

Step 2: Execute Test-NetConnection

After opening PowerShell, use the “Test-NetConnection” command and specify the port number and IP address to check out whether the port is open or close:

> Test-NetConnection -Port 8000 -ComputerName 192.168.0.1 -InformationLevel Detailed

If the output result does not show any warning or failed or timeout message and “TcpTestSucceeded” property value is set as “True”, its means that the port is currently opened:

The port is closed if the output displays the “TCP connect to (192.168.0.1: 8000) failed” warning:

We have elaborate the commonly used methods to check out if a port is open or closed on Windows Service.

Conclusion

To check if a port is open or closed on Windows Service, you can use the “telnet” or “netstat” utility on Command Prompt or utilize Windows PowerShell. To utilize Telnet on Windows, we need to enable it first. You can also use the netstat command-line tool to see whether a port is open or closed. For the specified purpose, the “Test-NetConnection” command can also be executed in PowerShell. This post demonstrated the simplest methods for determining whether a port is open or closed on a Windows service.

About the author

Rafia Zafar

I am graduated in computer science. I am a junior technical author here and passionate about Programming and learning new technologies. I have worked in JAVA, HTML 5, CSS3, Bootstrap, and PHP.