How do I find and kill the process holding a port on Windows?

Use PowerShell to identify the PID listening on a Windows port, kill it, and confirm the port is free.

WindowsProcessesnetworkTerminalportspowershelltaskkillMedium risk
Find the OwningProcess with Get-NetTCPConnection, then end that PID.

What this covers

Windows blocks the second process that tries to bind the same TCP port, often with “address already in use” or “Only one usage of each socket address is normally permitted.” The fix is to identify the exact PID listening on that port and stop it, then verify the port is free.

Symptom

?An app, dev server, or service fails to start because another process is already bound to the port. The message may mention EADDRINUSE, bind, or that only one usage of each socket address is permitted.

Find which process is listening on the port

Start here because the PID is what makes the next step safe and precise. Run the listener list, then filter it to the port from the error (for example, 8080 or 3000). The OwningProcess column is the PID you need; note it before moving on. If nothing is listening, the conflict may be from a UDP socket or another user session.

The PowerShell-native replacement for netstat: filter connections by state, port, or process and pipe results instead of parsing text.

Command
$ Get-NetTCPConnection -State Listen | Select-Object LocalAddress, LocalPort, OwningProcess

End the process by its PID

Use the OwningProcess number from the previous step wherever the command expects <PID>. This kills the process and any children it spawned, which is usually what you want for a dev server or app that left a worker behind. Confirm the PID is the one listening on your port before you force it.

End a process and everything it spawned, using the numeric PID you looked up.

Command
$ taskkill /PID <PID> /T /F
!Killing the wrong process can lose unsaved work or stop a Windows service. Match the PID to the expected listener, and use process-tree termination only when the child processes belong to that app.

How to confirm it worked

Test the port from the same machine: if nothing answers, the listener is gone. Then restart the app that needed the port.

Sources

  • PING - Windows CMD
    SS64 · technical · 2026-09-17
    Evidence: SS64 explains ping only tests ICMP echo, which many hosts and firewalls block, unlike a TCP port test.
  • Get-NetTCPConnection - PowerShell
    SS64 · technical · 2026-09-17
    Evidence: SS64 shows Get-NetTCPConnection usage with -State Listen and -LocalPort filters for listing bound ports.
  • Get-NetTCPConnection | Microsoft Learn
    Microsoft · vendor-doc · 2026-09-17
    Evidence: Microsoft documents Get-NetTCPConnection parameters including -State with the Listen value and the OwningProcess property returned for each connection.
  • taskkill — Microsoft Learn
    Microsoft · vendor-doc · 2026-09-21
    Evidence: /PID <processid> specifies the process to terminate; /T ends the specified process and any child processes started by it; /F forces termination.
  • taskkill — Windows CMD reference
    SS64 · technical · 2026-09-21
    Evidence: TASKKILL /PID pid /T /F terminates the given process and its child processes forcefully.
  • Test-NetConnection - PowerShell
    SS64 · technical · 2026-09-17
    Evidence: SS64 documents Test-NetConnection's -Port parameter for testing TCP connectivity and the TcpTestSucceeded result property.

Last verified: 2026-09-22

Related guides