MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

Windows Troubleshooting: Administrator Guide

To find which ports are in use on Windows, use netstat -ano in Command Prompt, Get-NetTCPConnection and Get-NetUDPEndpoint in PowerShell, or the graphical tools Resource Monitor and TCPView. This guide shows those methods, then explains how to read the output, match a port to its process or service, fix port conflicts and test whether a port can be reached.


How to check for used ports on Windows?

Using Command Prompt

  1. Netstat: This command displays active connections and listening ports.
    • Open Command Prompt (you can search for cmd in the Start menu).
    • Type netstat -ano and press Enter. This will list all ports in use along with the process IDs (PIDs) using them.
    • To find a specific port, you can use netstat -ano | findstr "PORT_NUMBER", replacing PORT_NUMBER with the port you’re interested in.
  2. TCPView: This is a graphical utility from Sysinternals that provides a more detailed view of TCP and UDP endpoints. You need to download it from Microsoft’s website.

Using PowerShell

  • Open PowerShell (you can search for powershell in the Start menu).
  • Run the following command: Get-NetTCPConnection | Where-Object { $_.LocalPort -eq PORT_NUMBER }, replacing PORT_NUMBER with the port you want to check.
  • Alternatively, you can use Get-Process -Id (Get-NetTCPConnection -LocalPort PORT_NUMBER).OwningProcess to get more information about the process that’s using the port.

Using Resource Monitor

  1. Open Resource Monitor, which can be found by searching in the Start menu or under the “Performance” tab of Task Manager.
  2. Go to the “Network” tab.
  3. Look at the “Listening Ports” section to see which ports are in use and by which processes.
Windows Resource Monitor Network tab with Listening Ports listing processes, PIDs and ports in use

Reading netstat output

netstat -ano prints one line per socket. -a shows all connections and listening ports, -n shows numbers instead of host and service names (much faster), and -o adds the owning process ID. A typical result looks like this:

  Proto  Local Address          Foreign Address        State           PID
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING       1032
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING       4
  TCP    127.0.0.1:5432         0.0.0.0:0              LISTENING       3920
  TCP    192.168.1.20:52144     20.190.151.7:443       ESTABLISHED     8812
  TCP    [::]:80                [::]:0                 LISTENING       4
  UDP    0.0.0.0:5353           *:*                                    2460Code language: CSS (css)
ValueMeaning
0.0.0.0:PORT or [::]:PORTListening on every IPv4 or IPv6 interface, so other machines can reach it unless the firewall blocks it
127.0.0.1:PORTListening only on loopback, so only the local machine can connect
LISTENINGA server socket waiting for connections. This is usually what blocks another app from using the port
ESTABLISHEDAn active connection. The local port is often a random high (ephemeral) port
TIME_WAITA recently closed connection. It clears on its own and shows PID 0
CLOSE_WAITThe remote side closed the connection but the local app has not. Many of these usually mean an application bug

UDP has no connections, so UDP lines have no state. To list one protocol only, use netstat -ano -p TCP or netstat -ano -p UDP.

Corrected port lookup commands

Some commands in the example above give misleading results. findstr "80" matches any line that contains those digits, including ports 8080 and 3380 and PIDs such as 1804. Search for the colon, the port and the space after it instead. /C: makes findstr treat the space as part of the search text rather than a separator:

netstat -ano | findstr /C:":8080 "

rem Only listening sockets on that port
netstat -ano | findstr /C:":8080 " | findstr LISTENINGCode language: JavaScript (javascript)

In PowerShell, filter with parameters instead of piping every connection through Where-Object. Add -State Listen to skip client connections. Add -ErrorAction SilentlyContinue because the cmdlet throws an error when nothing matches. Select-Object -Unique stops the same process appearing once for every connection:

# TCP listener on a port
Get-NetTCPConnection -LocalPort 8080 -State Listen -ErrorAction SilentlyContinue

# Process behind it (safe when nothing is found or many connections exist)
$pids = (Get-NetTCPConnection -LocalPort 8080 -ErrorAction SilentlyContinue).OwningProcess |
    Select-Object -Unique
if ($pids) { Get-Process -Id $pids } else { 'Port 8080 is not in use (TCP)' }

# UDP is separate: Get-NetTCPConnection never shows UDP ports
Get-NetUDPEndpoint -LocalPort 53 -ErrorAction SilentlyContinueCode language: PHP (php)

Note: Get-NetTCPConnection and Get-NetUDPEndpoint come from the NetTCPIP module. They are available in Windows PowerShell 5.1 and in PowerShell 7 on Windows, but not on Linux or macOS.

Listing every listening port with its process name

Use this report for a quick audit of a server. It shows every TCP listener and UDP endpoint with the process name, sorted by port:

$tcp = Get-NetTCPConnection -State Listen | ForEach-Object {
    [pscustomobject]@{
        Proto   = 'TCP'
        Address = $_.LocalAddress
        Port    = $_.LocalPort
        PID     = $_.OwningProcess
        Process = (Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue).ProcessName
    }
}
$udp = Get-NetUDPEndpoint | ForEach-Object {
    [pscustomobject]@{
        Proto   = 'UDP'
        Address = $_.LocalAddress
        Port    = $_.LocalPort
        PID     = $_.OwningProcess
        Process = (Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue).ProcessName
    }
}
$tcp + $udp | Sort-Object Proto, Port | Format-Table -AutoSizeCode language: PHP (php)

To save the report or compare it with another server, replace Format-Table -AutoSize with Export-Csv .\ports.csv -NoTypeInformation.

Finding the process, service or command line behind a PID

netstat only gives you a number. The example above does not show how to turn that number into a process in Command Prompt. Use tasklist with a filter:

rem Process name for PID 1032
tasklist /FI "PID eq 1032"

rem Services hosted inside that process (useful for svchost.exe)
tasklist /svc /FI "PID eq 1032"

rem Show the executable name next to each socket (needs an elevated prompt)
netstat -abnoCode language: JavaScript (javascript)

Many Windows services share a single svchost.exe process, so the process name alone is often not enough. In PowerShell you can see the full command line and any services in the process:

Get-CimInstance Win32_Process -Filter "ProcessId = 1032" |
    Select-Object ProcessId, Name, ExecutablePath, CommandLine

Get-CimInstance Win32_Service -Filter "ProcessId = 1032" |
    Select-Object Name, DisplayName, State, StartModeCode language: JavaScript (javascript)

Note: Run the console as Administrator. Without elevation, netstat -b fails and some processes show no path or command line because you do not have permission to see them.

Common port problems and fixes

SymptomLikely causeFix
Port shows PID 4 (System)The kernel owns it. Usually HTTP.sys (IIS, WinRM, WCF or other apps that reserve URLs), or SMB on 445Run netsh http show servicestate to see which app registered the URL, then stop that service (for example W3SVC for IIS) or change its binding
App says the port is in use but nothing is listening on itWindows has reserved the port range, often because of Hyper-V, WSL 2, Docker or WinNATRun netsh interface ipv4 show excludedportrange protocol=tcp and choose a port outside the reserved ranges
Many TIME_WAIT entries with PID 0Normal after short connections closeNo action needed unless ephemeral ports run out. Reuse connections in the client
No MSFT_NetTCPConnection objects foundNothing is using that portAdd -ErrorAction SilentlyContinue or treat the error as "port is free"
Port is listening but remote clients cannot connectIt is bound to 127.0.0.1, or Windows Firewall blocks itBind to 0.0.0.0 or the server IP, then check the firewall rules (see the next section)

Freeing a port safely

  1. Find the PID with netstat -ano | findstr /C:":8080 " or Get-NetTCPConnection -LocalPort 8080.
  2. Check whether the PID belongs to a service: tasklist /svc /FI "PID eq <PID>".
  3. If it is a service, stop it properly so it does not just restart: Stop-Service -Name <ServiceName>. To stop it starting at boot, also run Set-Service -Name <ServiceName> -StartupType Disabled.
  4. If it is an ordinary application, close it normally first. Force it closed only if you must: Stop-Process -Id <PID> or taskkill /PID <PID> /F.
  5. Check that the port is free with Get-NetTCPConnection -LocalPort 8080 -ErrorAction SilentlyContinue. An empty result means nothing is using it.

Note: Do not end PID 4, lsass.exe, wininit.exe or services.exe. Ending these crashes or restarts the system. Stop the service that registered the port instead.

Testing whether a port is reachable

A port can be listening on the server and still be unreachable from other machines. Test from the client side with Test-NetConnection:

Test-NetConnection -ComputerName server01 -Port 443

# Relevant part of the output
# RemoteAddress    : 10.0.0.15
# RemotePort       : 443
# TcpTestSucceeded : TrueCode language: PHP (php)

If TcpTestSucceeded is False but the server shows the port as LISTENING on 0.0.0.0, check the server's firewall for a rule that allows the port:

Get-NetFirewallPortFilter -Protocol TCP |
    Where-Object LocalPort -eq 8080 |
    Get-NetFirewallRule |
    Select-Object DisplayName, Enabled, Direction, Action, Profile

# Allow the port inbound if no rule exists (elevated prompt)
New-NetFirewallRule -DisplayName 'App 8080' -Direction Inbound -Protocol TCP -LocalPort 8080 -Action AllowCode language: PHP (php)

Note: Only open the ports a service needs, and limit the rule with -RemoteAddress or -Profile Domain where you can. Use the listening-ports report above to find services that are exposed by mistake. More cmdlets are covered in the PowerShell command line reference.

Frequently asked questions

How do I kill the process using a port on Windows?

Find the PID with netstat -ano | findstr /C:":PORT ", then run taskkill /PID <PID> /F or Stop-Process -Id <PID>. If the PID belongs to a service, stop the service with Stop-Service instead, or it may start again.

Why is port 80 or 443 used by PID 4 (System)?

PID 4 is the Windows kernel. A web port held by PID 4 usually means HTTP.sys has registered it for IIS, WinRM or another app that uses HTTP.sys. Run netsh http show servicestate to see which process registered the URL.

Do I need administrator rights to check open ports?

No. netstat -ano and Get-NetTCPConnection work in a normal console. You need an elevated prompt for netstat -b, which shows executable names, and to see details of processes run by other users or SYSTEM.

Why does Windows say a port is in use when netstat shows nothing on it?

Windows may have reserved the port in an excluded range, often for Hyper-V, WSL 2 or Docker networking. Run netsh interface ipv4 show excludedportrange protocol=tcp to see the reserved ranges, and choose a port outside them.

How do I check if a port is open on a remote Windows server?

Run Test-NetConnection -ComputerName <host> -Port <port> from the client and look at TcpTestSucceeded. If it is False, check that the service is listening on a reachable address and that the server's firewall allows the port.

Related tutorials

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

PowerShell Training for Developers: Course Outline, Labs, and Delivery Options

This revised guide summarizes the original PowerShell training offering for developers and build/release engineers, including syllabus, lab focus, and delivery details. It also adds practical command examples so you can evaluate fit before enrolling.

Read More

Perforce Network Troubleshooting: A Practical Workflow for Port, DNS, and Firewall Issues

This guide turns a classic Perforce troubleshooting checklist into a structured workflow you can run quickly during incidents. You will validate server listening state, P4PORT configuration, client connectivity, DNS, firewall rules, and network path health.

Read More

Junior Network Engineer: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path

The **Junior Network Engineer** supports the design, implementation, and day-to-day operation of the companyโ€™s network services across corporate and cloud-connected environments. The role focuses on maintaining reliable connectivity, resolving network incidents, executing standard changes, and improving observability and documentation under the guidance of senior engineers.

Read More

Lead Network Architect: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path

The Lead Network Architect designs and governs the enterprise network architecture that enables secure, reliable, high-performance connectivity across data centers, cloud environments, offices, and remote users. This role translates business and product needs (availability, latency, scale, compliance, cost) into network blueprints, standards, and roadmaps, and leads complex network transformations from concept through implementation and operational handoff.

Read More

Senior Windows Administrator: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path

The Senior Windows Administrator is accountable for the reliability, security, and operational excellence of the organizationโ€™s Windows-based infrastructure, including core identity services, server platforms, endpoint management integrations, and Windows-adjacent enterprise services. This role ensures that Windows environments are standardized, patched, monitored, recoverable, and compliantโ€”while progressively automating operations to reduce toil and improve service quality.

Read More

Senior Microsoft 365 Administrator: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path

The **Senior Microsoft 365 Administrator** is the technical owner and operational steward of the organizationโ€™s Microsoft 365 tenant(s), ensuring secure, reliable, and well-governed collaboration and productivity services across Exchange Online, Teams, SharePoint Online, OneDrive, and Microsoft Entra ID. This role designs and runs the service at enterprise scale: configuring identity and access controls, managing service health and changes, automating administration, and leading incident response for M365-related outages or degradations.

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x