Find and Free Busy Ports in Windows 10/11 with netstat and PowerShell
Difficulty: Intermediate | Time Required: 15 minutesCategory: Development Tools
Introduction
If you run development tools on Windows 10 or Windows 11, you will eventually see an error like “port already in use,” “address already in use,” or “failed to bind to port.” This commonly happens with web servers, Node.js apps, Docker containers, IIS Express, SQL tools, game servers, API emulators, and local test services.A “busy” port means another process is already listening on that TCP or UDP port. To fix it, you need to answer two questions:
- Which process is using the port?
- Can I safely stop that process or should I change my app’s port?
netstat command and modern PowerShell cmdlets.Prerequisites
Before starting, you need:- A Windows 10 or Windows 11 PC.
- Command Prompt, Windows Terminal, or PowerShell.
- Administrator access if you need to stop a process owned by another user or system service.
- The port number you want to check, such as
3000,5000,8080,1433, or5432.
Note: You can run most “find” commands without elevation, but stopping processes often requires Run as administrator.
Step 1: Open Command Prompt or PowerShell
- Right-click Start.
- Choose Terminal, Windows PowerShell, or Command Prompt.
- If you plan to stop a process, choose Run as administrator.
Step 2: Find a Busy Port with netstat
The fastest traditional method is:netstat -aon | findstr :8080Replace
8080 with the port you are checking.For example:
netstat -aon | findstr :3000You may see output similar to this:
TCP 127.0.0.1:3000 0.0.0.0:0 LISTENING 15432Here is what the columns mean:
- TCP or UDP: The protocol.
- Local Address: The local IP address and port.
- Foreign Address: The remote endpoint, if any.
- State: For TCP, this may show
LISTENING,ESTABLISHED,TIME_WAIT, and other states. - PID: The process ID that owns the connection or listening port.
15432.Why use -aon?
The flags are useful together:-ashows active connections and listening ports.-oshows the owning process ID.-ndisplays addresses and port numbers numerically, which is faster and avoids name lookups.
Tip: If you search for port80, usefindstr :80carefully. It may also match ports like8080or50080. Review the local address column to confirm the exact port.
Step 3: Identify the Process Name from the PID
Once you have the PID, usetasklist:tasklist /FI "PID eq 15432"Example output:
Code:
Image Name PID Session Name Mem Usage
========================= ======== ================ ============
node.exe 15432 Console 85,000 K
node.exe is using the port.You can also use PowerShell:
Get-Process -Id 15432For a cleaner view:
Get-Process -Id 15432 | Select-Object Id, ProcessName, PathNote: ThePathproperty may not always display unless your shell has enough permission to inspect that process.
Step 4: Find a Busy TCP Port with PowerShell
PowerShell provides a more structured way to inspect TCP connections.To check a specific port:
Get-NetTCPConnection -LocalPort 8080To show only listening TCP ports:
Get-NetTCPConnection -LocalPort 8080 -State ListenYou will see properties such as:
Code:
LocalAddress LocalPort State OwningProcess
------------ --------- ----- -------------
127.0.0.1 8080 Listen 15432
To combine the connection and process name:
Code:
Get-NetTCPConnection -LocalPort 8080 -State Listen |
ForEach-Object {
$process = Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue
[PSCustomObject]@{
LocalAddress = $_.LocalAddress
LocalPort = $_.LocalPort
State = $_.State
PID = $_.OwningProcess
ProcessName = $process.ProcessName
}
}
Step 5: Check UDP Ports
Get-NetTCPConnection is for TCP only. If you need to check UDP, use:Get-NetUDPEndpoint -LocalPort 5353To show the owning process:
Code:
Get-NetUDPEndpoint -LocalPort 5353 |
Select-Object LocalAddress, LocalPort, OwningProcess
Get-Process -Id <PID>Replace
<PID> with the value from OwningProcess.Tip: UDP does not have aLISTENINGstate like TCP. A UDP endpoint can still be bound to a local port even without a visible connection state.
Step 6: Free the Port Safely
Once you identify the process, decide whether it is safe to stop.Option A: Close the App Normally
If the process is a known application, close it first. Examples:- Stop the development server with Ctrl+C in its terminal.
- Close the app window.
- Stop the service from its own dashboard, such as Docker Desktop or a database tool.
Option B: Stop the Process with PowerShell
If you are sure the process can be stopped, run:Stop-Process -Id 15432 -ConfirmPowerShell will ask for confirmation before stopping it.
If you need to force it:
Stop-Process -Id 15432 -ForceWarning: Be careful with-Force. Stopping the wrong process can close apps, interrupt services, break active work, or destabilize Windows components.
Option C: Stop the Process with taskkill
From Command Prompt:taskkill /PID 15432If it refuses to stop:
taskkill /PID 15432 /FThe
/F switch forces termination.Step 7: Confirm the Port Is Free
After stopping the process, check again:netstat -aon | findstr :8080Or with PowerShell:
Get-NetTCPConnection -LocalPort 8080 -ErrorAction SilentlyContinueIf no matching listener appears, the port is free.
You can now restart your application.
Tips and Troubleshooting Notes
If the Port Still Appears Busy
Wait a few seconds and check again. TCP connections can briefly remain in states such asTIME_WAIT after an app closes. Usually this clears on its own.If the PID Belongs to a Service
Some ports are owned by Windows services, database engines, virtualization software, web servers, or security tools. Instead of killing the process, open Services:- Press Win + R.
- Type:
services.msc- Locate the service.
- Stop or restart it only if you understand what it does.
If You Keep Hitting the Same Conflict
Consider changing your application’s port. For example, if port3000 is busy, configure your dev server to use 3001 or 5173.Common Developer Ports to Check
80and443: Web servers3000,5173,8080: Web development servers5000,5001: .NET or API development1433: SQL Server3306: MySQL/MariaDB5432: PostgreSQL6379: Redis27017: MongoDB
Conclusion
Finding and freeing busy ports is an essential Windows troubleshooting skill for developers and power users.netstat is quick, reliable, and available everywhere. PowerShell gives you richer, object-based output that is easier to filter, format, and script.Use the PID to identify the owning process, stop it safely when appropriate, and always double-check before forcing a process to close.
Key Takeaways:
- Use
netstat -aon | findstr :PORTto quickly find what is using a port. - Use
Get-NetTCPConnection -LocalPort PORTfor a PowerShell-friendly TCP view. - Match the PID to a process with
tasklistorGet-Process. - Stop processes carefully with
Stop-Process,taskkill, or the app’s own shutdown method. - If the process is important, change your app’s port instead of killing the process.
This tutorial was generated to help WindowsForum.com users get the most out of their Windows experience.