Search Our Database
How to check and close open ports on Windows using PowerShell or netstat
Introduction
On Windows systems, applications and services communicate over specific network ports. Sometimes, ports remain open unnecessarily due to misconfigured software, unresponsive processes, or malicious applications. Open ports can create security risks and lead to conflicts with other services trying to use the same port.
Administrators often need to check which processes are using specific ports and, if necessary, close them. For example, if a web server (IIS, Apache, or Nginx) fails to start because port 80 is already in use, identifying and terminating the process holding the port resolves the issue.
Windows provides multiple ways to accomplish this. The two most common are:
- netstat (built into Windows, accessible via Command Prompt or PowerShell).
- PowerShell cmdlets for process and networking management.
Prerequisites
- Windows 7, 8, 10, or 11.
- Administrator privileges.
- Familiarity with Command Prompt or PowerShell.
Step-by-step Guide
Step 1: Open PowerShell or Command Prompt as Administrator
- Press Windows Key + S and type either powershell or cmd.
- Right-click the program and select Run as administrator.
Step 2: List Open Ports with netstat
To display active ports and their associated processes, run:
netstat -ano
This shows:
-
Proto: Protocol (TCP/UDP).
-
Local Address: IP and port number in use.
-
PID: Process ID of the program holding the port.
For example:
Proto Local Address Foreign Address State PID TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 1234
Step 3: Find Which Application Uses the Port
Once you have the PID, run this command in PowerShell or Command Prompt:
tasklist /fi "PID eq 1234"
Step 4: Close the Port by Terminating the Process
If the process is not required, it can be terminated using:
taskkill /PID 1234 /F
Replace 1234 with the actual PID.
Step 5: Alternative – Use PowerShell to Find and Close Ports
You can also use PowerShell cmdlets. For example, to check which process is using port 80:
Get-Process -Id (Get-NetTCPConnection -LocalPort 80).OwningProcess
To stop it:
Conclusion
Checking and closing open ports on Windows is an essential step for troubleshooting service conflicts and improving system security. Using netstat and PowerShell, administrators can quickly identify which processes occupy specific ports and safely terminate them if needed.
This ensures critical applications like web servers, databases, or remote desktop services can function without interference from unnecessary processes.
Should you have any inquiries about the guidelines, please feel free to open a ticket through your portal account or contact us at support@ipserverone.com. We’ll be happy to assist you further.