Find Process ID of Process using a Port in Windows

Find Process ID of Process using given port in Windows
Once a while it happens that you try to start Tomcat and it complains “Port 8080 required by Tomcat v7.0 Server at localhost is already in use”. So that means there is already a process running in background that has occupied 8080 port. So how to identify the process in Windows task manager that is using port 8080? I am sure there must be a javaw.exe. But is there a better way to identify which process in windows is using a given port number? Yes…

How to Find Process ID of process that uses a Port in Windows

Our friend netstat will help us in identifying the process. netstat can list the running process and display information such as process id, port, etc. From this list we can filter the processes that has given port using findstr command.

List process by port number

netstat -ano | findstr 8080
Code language: Bash (bash)
find process id by port number windows

Output

Proto Local Address Foreign Address State PID TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 29848
Code language: Bash (bash)
  • -a – Displays all connections and listening ports.
  • -o – Displays the owning process ID associated with each connection.
  • -n – Displays addresses and port numbers in numerical form.

We can use netstat to list all the processes.

List all processes by PID

netstat -ano
Code language: Bash (bash)

Kill the Process by PID

Once we identify the process PID, we can kill the process with taskkill command.

taskkill /F /PID 12345
Code language: Bash (bash)

Where /F specifies to forcefully terminate the process(es). Note that you may need an extra permission (run from admin) to kill some certain processes.

windows-task-manager-process-task-by-port-number

Or else you can use our old trusted Windows Task Manager to kill the process for given process id. If PID is not visible in your task manager then you can enable it by Right clicking on table header under Details tab, click Select Columns and then check PID.

Get our Articles via Email. Enter your email address.

You may also like...

3 Comments

  1. divp says:

    Thanks for sharing nice article

  2. Ap says:

    Is there any way to kill a process using a specific port in windows using a single command?

  3. Pablo says:

    Helpful. Thank you.

Leave a Reply

Your email address will not be published. Required fields are marked *