Windows Kill Process By PORT Number

Janaka Ekanayake picture Janaka Ekanayake · Mar 23, 2019 · Viewed 56.2k times · Source

I'm using embedded Tomcat server in Spring Tool Suite IDE. My problem is when I run my project there is an error as follows,

***************************
APPLICATION FAILED TO START
***************************

Description:

The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in use or the connector may be misconfigured.

Action:

Verify the connector's configuration, identify and stop any process that's listening on port 8080, or configure this application to listen on another port.

There are some similar questions but none of the answers not working for me.

Answer

Patel Romil picture Patel Romil · Mar 23, 2019

Solution 1: Kill Process

Run command-line as an Administrator

netstat -ano | findstr :<yourPortNumber>
taskkill /PID <typeyourPIDhere> /F

Solution 2: Change Port

Please Make sure that new port you are going to set for your Application doesn't listen to any other process

Change the port 
server.port=8088 # Server HTTP port.

Solution 3: Another way is to terminate the process (in IDE) and clean and rebuild project.

enter image description here

enter image description here

UPDATE:

For solution 2, Please Make sure that new port you are going to set for your Application doesn't listen to any other process.

How to check Port Status?

Option 1

Run resmon.exe and go to Network -> Listening Port (Also can be viewed on TaskManager) enter image description here


Option 2

PowerShell

Get-Process -Id (Get-NetTCPConnection -LocalPort portNumber).OwningProcess

cmd

 C:\> netstat -a -b

(Add -n to stop it trying to resolve hostnames, which will make it a lot faster.)

-a Displays all connections and listening ports.

-b Displays the executable involved in creating each connection or listening port. In some cases, well-known executables host multiple independent components, and in these cases, the sequence of components involved in creating the connection or listening port is displayed. In this case, the executable name is in [] at the bottom, on top is the component it called, and so forth until TCP/IP was reached. Note that this option can be time-consuming and will fail unless you have sufficient permissions.

-n Displays addresses and port numbers in numerical form.

-o Displays the owning process ID associated with each connection.