• Thread Author
When a Windows Server hosts services for users or other systems, port visibility is one of the first and most essential things an administrator must master; knowing which ports are listening, which are established, and which are blocked by a firewall directly affects uptime, security posture, and troubleshooting speed. This guide walks through three practical, built-in methods to check ports on Windows Server — Command Prompt (netstat), PowerShell (Test‑NetConnection and Get‑NetTCPConnection), and the graphical Resource Monitor — and expands into advanced diagnostics, common pitfalls, and security best practices every Windows admin should adopt.

Infographic showing listening ports and Windows monitoring tools.Background​

Ports are logical endpoints used by TCP and UDP to direct traffic to specific applications and services. On Windows Server, ports can be bound directly by apps (IIS, SQL Server, OpenSSH), by the kernel‑level HTTP.sys listener, or by system services running under svchost.exe. A port can appear “open” at the OS level yet be unreachable because of host firewall rules, network ACLs, NAT/port forwarding, or port reservation conflicts. Practical port checks therefore require verifying three layers:
  • Whether the OS process is listening on the port.
  • Whether the local host firewall allows the traffic.
  • Whether the network path (router, gateway, external firewall) permits connectivity.
Community troubleshooting discussions and operational guidance emphasize running checks from the server itself and from at least one remote host to capture both local and network-layer issues.

Quick summary of the three methods​

  • Command Prompt (netstat) — fast, universal, shows listening sockets and PIDs.
  • PowerShell (Test‑NetConnection, Get‑NetTCPConnection) — scriptable, gives connection success/failure, and richer object output.
  • Resource Monitor (GUI) — quick visual inspection for listening ports and the owning process.
The remainder of this article explains each method step‑by‑step, includes advanced options, and covers security implications and troubleshooting tips.

Method 1 — Check ports with Command Prompt (netstat)​

Why use netstat​

netstat is the classic, ubiquitous tool for seeing active TCP/UDP endpoints. It runs on any Windows Server build and produces immediate insight into which local addresses and ports are in use and which process (PID) owns each socket.

Common netstat commands and what they mean​

  • netstat -ano
  • -a shows all listening and established sockets.
  • -n displays numerical addresses and ports (no DNS resolution).
  • -o shows the PID (Process ID) that owns the socket.
  • netstat -abn
  • -b attempts to show the executable name(s) that created each socket (may require elevation and can be slow).
  • netstat -an | findstr :443
  • Filters output for a particular port (443 in this example).

How to run (step‑by‑step)​

  • Open Command Prompt as Administrator (important: many netstat flags require elevation).
  • Run: netstat -ano
  • Inspect lines with LISTENING to find local port numbers. Example output line:
  • TCP 0.0.0.0:443 0.0.0.0:0 LISTENING 1234
  • Note the PID (1234 here) and map it to a process:
  • tasklist /FI "PID eq 1234"
  • Alternatively, in Task Manager / Details tab, sort by PID.
  • If you need the process binary path and netstat -b didn’t work, use:
  • wmic process where processid=1234 get ExecutablePath
  • Or use PowerShell: Get-Process -Id 1234 | Select-Object Path
netstat gives a raw, reliable view of sockets; combining the PID with the service name quickly identifies misconfigurations (e.g., a service accidentally binding to port 80). Community troubleshooting commonly uses netstat as the first diagnostic step.

Strengths and limitations​

  • Strengths: Always available, low overhead, and fast.
  • Limitations: Output is textual (harder to parse programmatically unless you script), and netstat can’t test remote connectivity — only shows local listening state.

Method 2 — PowerShell: Test-NetConnection, Get-NetTCPConnection, and scriptable checks​

PowerShell provides modern, object‑oriented tools that are ideal for automation and remote tests.

Test-NetConnection — quick remote port check​

Test‑NetConnection performs a TCP connection attempt to a specified host and port and returns a boolean-style TcpTestSucceeded property, plus diagnostic details (RemoteAddress, PingSucceeded, and NetRoute information when available). It’s ideal to test from the server to a client or from a client to the server.
Example:
  • Test-NetConnection -ComputerName localhost -Port 443
The output includes TcpTestSucceeded which confirms whether a TCP handshake succeeded. This is the recommended way to confirm reachability from one host to another using PowerShell. Community guidance also notes that Test‑NetConnection may not exist in some PowerShell Core builds, so administrators should verify the environment if they receive a “term not recognized” error.

Get-NetTCPConnection — local socket inspection in PowerShell​

Get‑NetTCPConnection provides local socket details in objects that are easy to filter or export:
  • Get-NetTCPConnection -LocalPort 443
  • Get-NetTCPConnection | Where-Object { $_.State -eq 'Listen' } | Format-Table -AutoSize
You can combine Get‑NetTCPConnection with Get‑Process to map sockets to processes:
  • $conn = Get‑NetTCPConnection -LocalPort 443
  • Get‑Process -Id $conn.OwningProcess | Select-Object Id, ProcessName, Path

Scripting examples​

  • Check a list of ports and output CSV for documentation:
  • $ports = 80,443,8080
  • $ports | ForEach-Object { $p = $; Get‑NetTCPConnection -LocalPort $p -ErrorAction SilentlyContinue | Select-Object LocalAddress, LocalPort, State, @{Name='PID';Expression={$.OwningProcess}} } | Export-Csv ports.csv -NoTypeInformation
  • Test remote reachability for a host and port:
  • $host = 'server.example.local'; $port = 3389
  • Test-NetConnection -ComputerName $host -Port $port -InformationLevel Detailed

Strengths and limitations​

  • Strengths: Scriptable, returns structured objects, can test remote connectivity, and integrates with firewall cmdlets.
  • Limitations: Some cmdlets may vary across PowerShell versions; Test‑NetConnection’s detailed fields may differ in PowerShell Core. Always verify in your environment.

Method 3 — Resource Monitor (GUI) and other graphical tools​

Resource Monitor — quick visual check​

Resource Monitor (resmon.exe) includes a Network tab with a Listening Ports view showing:
  • Local Address and Port
  • Protocol (TCP/UDP)
  • Process name and PID
  • Remote Address/Remote Port for established connections
How to open:
  • Press Ctrl + Shift + Esc to open Task Manager.
  • Click Performance → Open Resource Monitor.
  • Go to the Network tab → Expand Listening Ports.
This is especially useful for administrators who prefer a GUI to rapidly scan which processes listen on which ports and to see current connections. The Resource Monitor view is functionally similar to netstat but presents information visually and allows you to click through to the owning process.

Sysinternals TCPView — advanced GUI​

For a more detailed GUI, Sysinternals TCPView provides a live, sortable list of all TCP and UDP endpoints, and can show the executable path and allow remote address / port filtering. TCPView is highly recommended in troubleshooting sessions because it updates in real time and gives deeper detail on established connections.

Strengths and limitations​

  • Strengths: Fast, intuitive, good for live monitoring and quick verification.
  • Limitations: Not as easily scriptable for reporting and automation.

Advanced diagnostics and common gotchas​

Verify firewall rules (Windows Defender Firewall / WFAS)​

Even if a service is listening, the host firewall may block traffic. Use PowerShell to inspect and create rules:
  • Get-NetFirewallRule -DisplayName "Allow SSH TCP 22" | Get-NetFirewallPortFilter
  • New-NetFirewallRule -DisplayName "Allow HTTP-alt TCP 8080" -Direction Inbound -Protocol TCP -LocalPort 8080 -Action Allow -Profile Domain,Private -RemoteAddress LocalSubnet
Always test from a client after changing firewall rules and verify the rule is enabled. Community operations guidance highlights verifying both the rule and the actual listen state — opening a firewall port without a listening service creates unnecessary attack surface.

HTTP.sys reservations and URLACL conflicts​

Services that rely on HTTP.sys (IIS, WCF, certain web services) may be impacted by URL reservations. Use netsh to list URLACLs:
  • netsh http show urlacl
A port can appear bound or claimed by HTTP.sys even if no visible process owns it; resolving HTTP.sys conflicts commonly appears in troubleshooting threads and requires checking URLACL and reserved prefixes. If you suspect HTTP.sys or URLACL is blocking an intended binding, inspect the URL reservations and remove or adjust them carefully.

Port reservations and programmatic rules​

Some services use port reservations or kernel-level listeners. When a port seems “in use” but no user process owns it, consider examining:
  • netsh http show urlacl
  • sc queryex for service PIDs
  • netstat -ano combined with Get-Process to map PIDs

IPv6 vs IPv4 behavior​

When testing ports on localhost or between hosts, IPv6 may introduce unexpected routing and test results. Administrators have encountered cases where Test‑NetConnection fails due to IPv6 routing quirks; a documented safe approach is prefer IPv4 over IPv6 via the DisabledComponents registry setting rather than disabling IPv6 entirely. Apply such changes with caution and reboot after changes. If you see an odd failure on localhost, confirm which IP stack the client and server prefer.

Port scanning and legal/ethical considerations​

Tools like Nmap and PortQry are useful for external testing, but scanning networks you do not own, or without authorization, may violate policy or law. Always run scans from systems you own or after explicit permission. Use port scans responsibly as part of sanctioned security assessments.

Troubleshooting checklist — step‑by‑step​

  • Confirm the service is configured to listen on the expected port (app config or service binding).
  • On the server, run netstat -ano | findstr :<port> and note the PID.
  • Map PID to process: tasklist /FI "PID eq <pid>" or Get-Process -Id <pid>.
  • Check local firewall rules: Get-NetFirewallRule and ensure an inbound rule allows the traffic for the correct profile.
  • Test connectivity locally: Test‑NetConnection -ComputerName localhost -Port <port>.
  • Test connectivity from a client on the same network: Test‑NetConnection -ComputerName <server-ip> -Port <port>.
  • If blocked externally but not locally, check network firewalls, routers, and NAT rules.
  • If port is “in use” but no process is obvious, check HTTP.sys URLACLs: netsh http show urlacl.
  • If intermittent failures, use TCPView or Resource Monitor for live observation.

Security best practices when opening ports​

Opening ports increases attack surface. Apply the following principles:
  • Least privilege: Only open required ports and only to the smallest set of remote addresses necessary. Prefer scoping rules to management IP ranges rather than “Any”.
  • Program-bound rules: Where possible, permit traffic tied to the specific executable rather than only by port.
  • Logging and monitoring: Enable firewall logging and collect netflow/packet logs for suspicious activity.
  • Use encryption and authentication: For internal-only services, prefer IPsec or mutual authentication instead of exposing plaintext services to broader networks.
  • Harden services listening on public ports: Keep the software up to date, restrict admin interfaces, and instrument detection/response.
These are standard operational recommendations for minimizing exposure and improving forensic visibility.

Example scenarios and specific commands​

Example 1: Find what’s binding port 80 and open it in the firewall if needed​

  • netstat -ano | findstr :80
  • Suppose PID = 2340. tasklist /FI "PID eq 2340"
  • If it’s a web server, ensure firewall rule exists:
  • Get-NetFirewallRule -DisplayName "Allow HTTP" or to create:
  • New-NetFirewallRule -DisplayName "Allow HTTP" -Direction Inbound -Protocol TCP -LocalPort 80 -Action Allow -Profile Any
  • Test from remote host: Test-NetConnection -ComputerName <server-ip> -Port 80

Example 2: Script to verify a list of ports and report which are listening​

  • $ports = @(22,80,443,1433,3389)
  • foreach ($p in $ports) { $l = Get-NetTCPConnection -LocalPort $p -ErrorAction SilentlyContinue; if ($l) { "$p LISTENING - PID $($l.OwningProcess)" } else { "$p NOT LISTENING" } }

Example 3: Check a remote host’s port with fallback to Test‑NetConnection alternatives​

  • Test-NetConnection -ComputerName remote.example.com -Port 8080 -InformationLevel Detailed
  • If Test‑NetConnection is unavailable (PowerShell Core), use tcping or invoke a TCP socket via .NET in PowerShell as a fallback.

When built‑in tools aren’t enough​

For deeper network diagnostics and security assessments, administrators may use third‑party tools:
  • Nmap — for comprehensive port scanning (use with authorization).
  • PortQry — lightweight Microsoft tool for port status checks.
  • Wireshark — packet capture for protocol-level debugging.
  • Sysinternals tools (TCPView, Process Explorer) — for deeper process–socket correlation.
Always weigh operational impact and authorization before running scans or packet captures on production networks.

Final analysis — strengths, risks, and recommended workflow​

Checking ports on Windows Server is straightforward with built‑in tools, but a disciplined workflow is essential:
  • Start local (netstat or Get‑NetTCPConnection) to confirm the server is listening.
  • Verify host firewall rules (Get‑NetFirewallRule).
  • Test remote connectivity (Test‑NetConnection, from multiple client locations if possible).
  • Use GUI tools (Resource Monitor, TCPView) for real‑time inspection and quick confirmations.
  • Escalate to packet capture or port scanning only when needed and after obtaining proper authorization.
Strengths of the built‑in approach include availability, low overhead, and scriptability. Key risks are human: opening unnecessary ports, mis-scoped firewall rules, or failing to account for HTTP.sys and URLACL reservations which can silently block expected bindings. Administrators should document port usage, enforce least privilege, and automate periodic port verification as part of change control and security reviews. Community evidence and operational documentation consistently recommend pairing netstat and PowerShell checks with firewall rule audits to avoid false positives when ports appear closed or open.

Closing recommendations (operator checklist)​

  • Maintain a documented map of which services should listen on which ports, including protocol (TCP/UDP), allowed source IP ranges, and whether encryption is required.
  • Add port verification into server build scripts: after service install, run netstat and Test‑NetConnection checks and fail the build if expected ports are not listening.
  • Schedule periodic audits: script Get‑NetTCPConnection and firewall rule exports to detect drift.
  • Use program-bound firewall rules whenever possible and avoid wildcard “Any” inbound rules.
  • When troubleshooting, always confirm whether the problem is local (server not listening), host‑firewall related, or network/perimeter related — test from both server and remote client perspectives.
Being methodical about port checks reduces mean time to resolution and hardens servers against accidental exposure. Use the three methods described — netstat, PowerShell, and Resource Monitor — as complementary tools in your operational toolbox.
Source: Windows Report How to Check Ports in Windows Server [3 Methods]
 

Back
Top