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 : java.net.BindException: Address already in use: bind
Solutions
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
- Go to (Open) Command Prompt (Press Window + R then type cmd Run this).
- 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
Steps to kill Tomcat Process by script
- Step 1: Copy below script in note pad and save it with extension as .bat
@ECHO OFF
netstat -aon |find /i "listening"
SET killPORT=
SET /P killPORT=Enter port:
IF "%killPORT%"=="" GOTO Kill
netstat -aon |find /i "listening" | find "%killPORT%"
:Kill
SET killPID=
SET /P killPID=Enter PID to kill:
IF "%killPID%"=="" GOTO Error
ECHO Killing %killPID%!
taskkill /F /PID %killPID%
GOTO End
:Error
ECHO No Process to kill!
:End
pause
- 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.
One thought on “Window : How to Kill/Stop tomcat service from command line?”
You must log in to post a comment.