Apache Tomcat Health Check

Kevin FOO
Oct 31, 2022

--

Normally Apache Tomcat comes with the default index.html file. So if you go to http://localhost:8080/index.html with your web browser it will serve you the index.html file with HTTP status 200.

At the terminal, the HTTP status can be obtained with the following command.

curl -sI http://localhost:8080/index.html|head -1|awk '{print $2}'

This works if the Apache Tomcat is serving a file. What if it is a load balancer that listens to port 8080 but does not serve any files. To test if it is working and listening to port 8080. Use the following command.

nc -z localhost 8080 2>&1|grep succeeded|wc -l

If successful, the result is 1. If unsuccessful, the result is 0.

< Back to all the stories I had written

--

--

Kevin FOO
Kevin FOO

Written by Kevin FOO

A software engineer, a rock climbing, inline skating enthusiast, a husband, a father.

No responses yet