Let us brief you on what ports are and why they can be dangerous.

What are network ports?

Network ports are used by Windows services and applications to send and receive data over the network. If you wonder if this is what the IP address is used for, then you are absolutely correct. However, a unique IP address defines the path to a specific device, whereas a port defines what application or service on that particular device to send that information to. Just like the IP addresses, a port is also unique within its ecosystem. Meaning, the same port cannot be used by two different services/applications. Therefore, both of these unique identifiers, the IP address, and the port number, are used to send and receive information from a computer. A port number can be found suffixed to an IP address, as in the example below: Here, the numbers followed by the colon denote the port number. Below are a few ports used by certain services and applications by default:

FTP – 21SSH – 22Telnet – 23SMTP – 25DNS – 53DHCP – 67 & 68HTTP – 80 & 8080HTTPS – 443SNMP – 161RDP – 3389

A single IP address can have 65535 TCP and 65535 UDP ports in total.

Are open network ports dangerous?

Not all ports that are listening are dangerous. Sometimes an application opens the ports automatically without informing the users. If the application is poorly constructed and the security protocols lack the basic infrastructure, an attacker might exploit those and infiltrate your PC. An open networking port is not always dangerous, but it is always better to keep your guard up and close any ports that are not required.

2 ways to check which ports are open/listening in Windows 10

You can figure out which ports are currently open on your computer, even if the installed applications did not inform you that they are using them. Here are 2 ways to check which ports are open and which service/application uses them on your local computer before you proceed to block them. Here is a guide to check if a remote network port is open.

Determine open ports with process name using Command Prompt

Some applications give out the name of the application/service associated with a port number. You can use the below-given command in Command Prompt to determine which ports are open and what are the names of the associated applications. Since the IP address assigned to our computer is 10.0.0.31, it displays different ports used by various applications suffixed to the IP address. However, as you may notice, some of the names of the services and applications are unidentifiable. For that, we shall adopt the second method.

Determine open ports with process ID using Command Prompt

In this approach, we shall be comparing the process IDs of the running applications and services associated with the ports and then determining the name of the process using the Task Manager. Here is how to do so: Now you have sufficient information on the ports you would like to close, if any. Proceed to the next step to block/close any listening ports on your computer.

How to close an open port

If you have found a port that you are no longer using or are not sure if it is secure to keep open, you should preferably block it. If you wish to close an open port, you can do so with Windows Firewall  or Windows Defender in case of Windows 10. You have now successfully disabled the port. You can repeat the steps to block additional ports or delete this one by navigating to the Inbound rules and removing the respective rules.

How to quickly close ports using Command Prompt

A couple of commands can be used to identify the processes that have opened the ports and then close the ports by killing the process. Please note that this is a quick and temporary way of closing the port using the command prompt. If you want to permanently block the port from opening again, you should follow the first method given above.

How to block network ports in Windows Firewall using Command Prompt

Block port in Windows Firewall using command line

You can also permanently block ports in Windows Defender Firewall using the Command Prompt. To create a block port rule in Windows Firewall, run the following command in Command Prompt: Replace Rule Name with your own rule name, for example, since I’m blocking IMAP port, I’ll name the rule as Block IMAP. Replace TCP with either RCP or UDP, whichever port you want to block. Replace 993 with the actual port number you want to block.

Unblock/Open port in Windows Firewall using command line

To open the port again, simply run the following command in CMD: Replace Rule Name with the actual rule name, Block IMAP in my case. This will delete the rule that we created above.

Closing words

Listening ports are not always dangerous, as it is very much dependent on what application/service it is open through. Nonetheless, it is still important not to give the attacker any chance to exploit your system’s vulnerabilities and wise to close any ports that are not being used. Also see:

How to Check if Windows Firewall is Blocking PortsFind Which App Is Listening On Which Port In WindowsHow To Block Or Allow Websites, IPs, Apps, And Ports Using Windows Firewall And PowerShellHow To Open RDP Port To Allow Remote Desktop Access To Your SystemHow to Allow Ping From Firewall in Windows Server (2022, 2019, 2016)