How To Check For Open Ports On Windows

7 min read

How to Check for Open Ports on Windows

Introduction
When you need to verify whether a specific service is listening on your Windows machine, the process of checking for open ports becomes essential. Open ports indicate that a network application is actively accepting connections, which can be useful for troubleshooting, security audits, or configuring remote access. This guide walks you through several reliable methods—using the Command Prompt, PowerShell, and built‑in Windows tools—to check for open ports on Windows efficiently and accurately.


1. Understanding Ports and Why You Need to Check Them

A port is a communication endpoint defined by a 16‑bit number (0‑65535). It works together with an IP address to uniquely identify a process on a network. Common ports include:

  • Port 80 – HTTP web traffic (often TCP)
  • Port 443 – HTTPS secure web traffic (usually TCP)
  • Port 22 – SSH (typically TCP)
  • Port 25 – SMTP email (often TCP)

If a port is open, a listening service is waiting for incoming connections. If it is closed or filtered, the request will be rejected or dropped. Knowing which ports are open helps you:

  • Confirm that a server application is running
  • Detect unexpected services that could be security risks
  • Ensure firewall rules are correctly applied

2. Prerequisites

Before you begin, make sure you have administrative privileges on the Windows computer. Most commands that display active connections require elevated rights; otherwise, you may only see a limited subset of ports.

You will also need one of the following Windows utilities:

  • Command Prompt (cmd.exe)
  • PowerShell
  • Windows Resource Monitor (optional GUI method)

3. Method 1 – Using the Command Prompt (netstat)

3.1 Basic netstat Command

Open Command Prompt as administrator and run:

netstat -ab
  • -a lists all active connections and listening ports.
  • -b attempts to show the executable associated with each port (requires admin).

The output displays lines such as:

Proto  Local Address   Foreign Address   State        PID
TCP    0.0.0.0:80      0.0.0.0:0         LISTENING    1245
TCP    127.0.0.1:22    0.0.0.0:0         LISTENING    3421

Key points

  • Local Address shows the IP and port number.
  • State indicates whether the port is LISTENING, ESTABLISHED, or CLOSED.
  • PID (Process ID) lets you map the port to a specific program.

3.2 Filtering for Specific Ports

If you only care about a particular port, pipe the output to findstr:

netstat -ab | findstr ":80"

This quickly isolates all entries that include port 80, making it easier to verify that the web server is indeed listening.

3.3 Exporting Results

To save the list for later analysis, redirect the output to a file:

netstat -ab > C:\temp\portlist.txt

You can then open the file with Notepad or any text editor.


4. Method 2 – Using PowerShell

PowerShell offers more flexible object‑oriented capabilities.

4.1 Get-NetTCPConnection

Run PowerShell as administrator and execute:

Get-NetTCPConnection | Format-Table -AutoSize

This cmdlet returns a table with columns such as LocalAddress, LocalPort, RemoteAddress, RemotePort, and OwningProcess Took long enough..

Example output

LocalAddress : 0.0.0.0
LocalPort    : 80
RemoteAddress : 0.0.0.0
RemotePort    : 0
State        : Listen
OwningProcess : 1245

4.2 Filtering by Port Number

To see only port 443, use:

Get-NetTCPConnection -LocalPort 443 | Format-Table

4.3 Retrieving the Executable Name

Combine Get-NetTCPConnection with Get-Process to display the program name:

Get-NetTCPConnection | ForEach-Object {
    $proc = Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue
    [PSCustomObject]@{
        Port      = $_.LocalPort
        Protocol  = 'TCP'
        Process   = $proc.Name
    }
}

The resulting objects show which application is bound to each open port.

4.4 UDP Ports

For UDP connections, use Get-NetUDPEndpoint (available in newer Windows versions):

Get-NetUDPEndpoint | Format-Table

UDP does not have a "listen" state, but the cmdlet lists all bound UDP ports And that's really what it comes down to..


5. Method 3 – Using Windows Resource Monitor (GUI)

If you prefer a visual approach, the Resource Monitor provides an intuitive view.

  1. Press Win + R, type resmon, and press Enter.
  2. manage to the Network tab.
  3. Expand the Listening Ports section.

You will see a list of ports, the associated PID, and the corresponding process name. This method is handy for quick checks but lacks the depth of command‑line tools for scripting or bulk analysis.


6. Interpreting the Results

When you check for open ports on Windows, pay attention to three critical pieces of information:

  • Port Number – Identifies the service.
  • Protocol (TCP/UDP) – Determines how data is transmitted.
  • Process/Service – Shows which application is responsible.

A port marked as LISTENING means the service is ready to accept connections. If you see a port you did not expect, investigate the owning process. Unexpected processes listening on common ports (e.g., 22, 3389) may indicate malware or misconfiguration It's one of those things that adds up..


7. Securing Your Open Ports

After you have identified the open ports, consider these best practices:

  • Enable Windows Defender Firewall rules that restrict inbound traffic to trusted IP ranges.
  • Disable unnecessary services via `services

msc** and set startup type to Disabled for services you do not use That's the part that actually makes a difference..

  • Patch regularly — outdated applications listening on open ports are common attack vectors.
  • Restrict remote management ports such as RDP (3389) and SSH (22) to VPN access or specific administrative hosts.
  • Review periodically — port exposure changes as you install new software, so make port auditing part of your routine.

For a repeatable audit, you can combine the techniques above into a scheduled script that logs listening ports and alerts you when an unexpected entry appears. Consistency matters more than any single tool; a port that was safe last month may become a liability after a new install or update The details matter here..

It sounds simple, but the gap is usually here.


8. Quick Reference Summary

Method Tool Best For
Command line netstat -ano Universal, fast, available on every Windows version
PowerShell Get-NetTCPConnection Scripting, filtering, object-based output
GUI Resource Monitor (resmon) Visual inspection, no commands needed

Not the most exciting part, but easily the most useful.

Each approach answers the same core question—what is listening on this machine and why—but they differ in depth and automation. Use netstat when you are on an unfamiliar system, PowerShell when you need to build reusable checks, and Resource Monitor when a quick visual overview is enough And that's really what it comes down to..


9. Conclusion

Knowing how to check for open ports on Windows is a fundamental skill for both everyday administration and security hardening. Even so, by correlating the port number, protocol, and owning process, you gain a clear picture of your system's network exposure. Start with netstat -ano for immediate results, graduate to Get-NetTCPConnection for scriptable precision, and rely on Resource Monitor when a graphical view is more convenient Still holds up..

Treat port auditing as an ongoing habit rather than a one-time task. Regular checks, disciplined firewall rules, and disabled unnecessary services together form a strong baseline defense—keeping your machine's doors open only to the services that genuinely need to be reachable, and closed to everything else.

10. Building a Portable Audit Script

Since Section 7 mentioned a scheduled script for repeatable audits, here is a ready-to-deploy PowerShell example. In real terms, it captures every listening TCP/UDP endpoint, resolves the owning process name and path, flags ports that are not in an approved allow-list, and writes a timestamped CSV log. But save it as Audit-Ports. ps1 and register it with Task Scheduler to run daily under the SYSTEM account for maximum visibility.

<#
.SYNOPSIS
    Logs all listening ports with process details and flags unexpected entries.
.NOTES
    Requires PowerShell 5.1+ (built into Windows 10/11/Server 2016+).
#>

[CmdletBinding()]
param (
    [string[]]$AllowList = @(22, 80, 443, 3389, 5985, 5986),  # adjust to your environment
    [string]$LogPath   = "C:\Logs\PortAudit_$(Get-Date -Format 'yyyyMMdd').csv"
)

# Ensure log directory exists
$logDir = Split-Path $LogPath -Parent
if (-not (Test-Path $logDir)) { New-Item -ItemType Directory -Path $logDir -Force | Out-Null }

# Gather connections + process info in one pipeline
$connections = Get-NetTCPConnection -State Listen -ErrorAction SilentlyContinue |
    Select-Object LocalAddress, LocalPort, OwningProcess,
        @{Name='ProcessName'; Expression={(Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue).ProcessName}},
        @{Name='ProcessPath'; Expression={(Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue).Path}},
        @{Name='Protocol'; Expression={'TCP'}} |

Get-NetUDPEndpoint -ErrorAction SilentlyContinue |
    Select-Object LocalAddress, LocalPort, OwningProcess,
        @{Name='ProcessName'; Expression={(Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue).That said, processName}},
        @{Name='ProcessPath'; Expression={(Get-Process -Id $_. OwningProcess -ErrorAction SilentlyContinue).
Just Came Out

Coming in Hot

Curated Picks

We Picked These for You

Thank you for reading about How To Check For Open Ports On Windows. We hope the information has been useful. Feel free to contact us if you have any questions. See you next time — don't forget to bookmark!
⌂ Back to Home