Window : How to Kill/Stop tomcat service from command line?

Generally, when run tomcat by eclipse or use embedded tomcat with spring and suddenly close eclipse. But in background tomcat is running. When you try to run tomcat again you will face below exception:

[Solved] Tomcat : Address already in use: bind


There are two ways to kill tomcat process:

  • Manually kill tomcat process from command line
  • Create script to kill tomcat processes

Manually  kill Tomcat Process from Command line

  1. Go to (Open) Command Prompt (Press Window + R then type cmd Run this).
  2. Run following commands to get all listening ports (If tomcat runnig on other ports apart from 8080)

netstat -aon | find /i "listening"

Apply port filter If you know port number

netstat -aon |find /i "listening" |find "8080"

As in below screen you will get PID and then  run the following command to kill the process

3 Copy PID from result set

taskkill /F /PID

Ex: taskkill /F /PID 13332

Kill Tomcat process from command line

Steps to kill Tomcat Process by script

  • Step 1: Copy below script in note pad and save it with extension as .bat

netstat -aon |find /i "listening"

SET /P killPORT=Enter port: 
IF "%killPORT%"=="" GOTO Kill

netstat -aon |find /i "listening" | find "%killPORT%"

SET killPID=
SET /P killPID=Enter PID to kill: 
IF "%killPID%"=="" GOTO Error

ECHO Killing %killPID%!
taskkill /F /PID %killPID%

ECHO No Process to kill!

  • Steps 2: Click  on saved batch file you will get list of all running processes on ports.
  • Step 3: Enter port which you want to kill. Script will return PID for same .
  • Step 4: Enter PID which you want to kill then your tomcat will stop.

Kill Tomcat process by script

One thought on “Window : How to Kill/Stop tomcat service from command line?”