When working with Windows, multiple applications or services may attempt to use the same network port. However, a specific IP address and port combination cannot generally be shared by multiple applications listening on the same protocol.
As a result, you may encounter errors indicating that the requested port is already in use by another application, or your service may start successfully but fail to establish connections.
To resolve this confliction problem, you need to identify the process occupying the port on your Windows VPS and terminate it to make the port available. In this guide, we’ll show you how to find listening ports, identify the process, and stop it using Command Prompt (CMD) and Windows PowerShell.
Find Listening Ports on Windows Using CMD
You can use the netstat command in Command Prompt to display active network connections and listening ports. If you’ve previously used netstat on a Linux VPS, you’ll find that the Windows version works similarly, and many of the same command options are available.
First, open CMD by searching for cmd in the Windows Start menu and run it as administrator. After running it, enter the following command to display all listening TCP ports:
netstat -ano | findstr LISTENING TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 1252
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:3389 0.0.0.0:0 LISTENING 1452Review the output to find the ports currently listening on your Windows system. The command output displays important columns, described in the table below:
| Column | Description |
|---|---|
| Local Address | Local IP address and port number used |
| Foreign Address | Remote IP address and port |
| State | Connection status, such as LISTENING |
| PID | Process ID associated with the connection. (ID of the process using the port). |
Example:
For example, if you see 0.0.0.0:8080 in the local server address column, which is the first one, it means a process is listening on the port 8080 on all IPv4 network interfaces. In the last column, you can find the process ID, which can be used to kill the process.
Find a Specific Listening Port
If you already know which port you want to check, you can filter the netstat output instead of listing every listening port with the previous command we’ve used.
For example, to check whether port 8080 is listening, run the command below. You can replace the port 8080 with your desired port and use the command.
netstat -ano | findstr :8080Check the Local Address and State columns to determine whether the port is listening or not. If not outputs returned it means the port is not listening to any connection and its availeble to use for other services.
Note:
This filter may also return connections where port 8080 appears in the Remote Address column. Check the Local Address and State columns to confirm whether the port is listening locally. Ports shown under Remote Address represent the destination ports of outgoing connections, not locally listening ports.
Kill process running on Windows with CMD
After identifying the listening port and its associated process ID (PID), you can use the taskkill command in Command Prompt to terminate the process and free up the port.
Identify Process on Windows With PID
Since the previous command shows only the process ID (PID) and doesn’t show the process name itself to be sure what we want to terminate, first we should find the process itself with the tasklist command.
Use the following command, replacing Proccess_ID with your obtained process ID from the netstat output.
tasklist /FI "PID eq Proccess_ID"This displays the application or service associated with that PID. Make sure you identify the correct process before terminating it.
For example, we used PID 1252, which belongs to a Windows system process communicating through the loopback IP address 127.0.0.1.
tasklist /FI "PID eq 1252"Image Name PID Session Name Session# Mem Usage
========================= ======== ================ =========== ============
svchost.exe 1252 Services 0 21,704 KWarning:
Do not terminate processes associated with essential Windows system files or background services, as doing so may cause system instability, interrupt critical services, or lead to unexpected errors.
You can also use Windows Task Manager to identify the processes by PID. In the Task Manager > Details section, you can find the name of the process using the PID.
Terminate Process Using taskkill on Windows
Once you’ve confirmed which process is using the port, you can run the following command by replacing Process_ID with your PID:
taskkill /PID Process_ID If Windows cannot terminate the process normally, or you need to force its termination, use the /F parameter.
taskkill /PID Proccess_ID /FNote:
The /F parameter forces the process to terminate. However, this may cause unsaved data to be lost or interrupt services that depend on the process.
After terminating the process, check whether the port is still listening or not. Replace the port with your port. If running the command below you don’t get any output it means the port is no longer listening to the port.
netstat -ano | findstr :portFind Listening Ports Using PowerShell on Windows
PowerShell provides another way to list listening TCP ports and their associated process IDs. First, open PowerShell as an administrator by searching for PowerShell in the Windows Start Menu and clicking Run as administrator. Then run the command below to check ports:
Get-NetTCPConnection -State ListenLocalAddress LocalPort RemoteAddress RemotePort State AppliedSetting
------------ --------- -------------- ---------- ------- --------------
127.0.0.1 65001 0.0.0.0 0 Listen
127.0.0.1 62522 0.0.0.0 0 Listen
127.0.0.1 55000 0.0.0.0 0 ListenAs you can see, the default PowerShell output does not display the PID. However, you can include it by explicitly requesting the OwningProcess property. Run the following command to display the PID alongside the other connection details.
Get-NetTCPConnection -State Listen | Select-Object LocalAddress, LocalPort, State, OwningProcessLocalAddress LocalPort State OwningProcess
------------ --------- ----- -------------
:: 49709 Listen 816
::1 49670 Listen 4880
:: 49669 Listen 4568Note:
In the output above, the OwningProcess column contains the Process ID (PID). You can copy this value and use it to terminate the associated process.
To check a specific port, such as 8080, use the following command. You can replace the 8080 with any port you want.
Get-NetTCPConnection -LocalPort 8080 -State Listen | Select-Object LocalAddress, LocalPort, OwningProcessKill a Running process on Windows with PowerShell
Once you’ve found the listening port and its associated PID using PowerShell, you can use PowerShell’s Get-Proccess and Stop-Proccess commands to identify and terminate the process.
Identify Process Using PowerShell on Windows
Use the following command to find the application or service associated with the PID (OwningProcess) returned by Get-NetTCPConnection. Replace the Proccess_ID with your PID.
Get-Process -Id Proccess_ID Kill process on port Windows PowerShell
After identifying the process and verifying that it is not a Windows service or Windows core process, you can use the command below to terminate the process. Replace Proccess_ID with your PID
Stop-Process -Id Proccess_IDIf the process failed to terminate, you can terminate it by force using -Force parameter.
Stop-Process -Id Proccess_ID -ForceAfter terminating the process, run the original command again to check whether any service or process is listening to your desired port. If no results are returned, there are no TCP listening connections on that local port.
Get-NetTCPConnection -LocalPort 8080 -State ListenConclusion
To stop a process using a specific port in Windows, you have several options. You can use either CMD or PowerShell to list the ports currently in use, identify the associated processes, check what they are used for, and terminate the processes if necessary.
In this guide, we’ve covered both methods. However, before terminating any process, make sure you understand what it does and which application or service depends on it. If the port is being used by essential Windows components or background services, don’t terminate them. Instead, consider using a different port for your application.
If you’ve terminated the process but still cannot establish a connection through the port, Windows Firewall may be blocking the incoming traffic. In this case, you may need to create a firewall rule to allow connections through that port. Follow our guide to learn how to allow a port through Windows Firewall.


