Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have installed Monit using the following command in Ubuntu Linux 12.04.1 server

sudo apt-get install monit

My main goal in using Monit is to restart my - MySQL and Apache tomcat services automatically when they are killed/stopped.

#Check and restart mysql service
check process mysqld with pidfile "/run/mysqld/"
group database
start program = "/etc/init.d/mysql start"
stop program = "/etc/init.d/mysql stop"
if failed host port 3306 protocol mysql then restart
if 5 restarts within 5 cycles then timeout

The above code works perfectly and Monit restarts MySQL service (when its killed/stopped).

I have actually configured tomcat as follows: - Downloaded the tomcat zip and extracted to a particular location - Configured this as my daemon service (and my tomcat server works properly).

As I don't have pid file for this tomcat setup, I am planning to check tomcat's status and start it using the following code:

#Check and restart tomcat service
check host tomcat with address
stop program = "/etc/init.d/tomcat stop"
start program = "/etc/init.d/tomcat start"
if failed port 8080 and protocol http
then start

However, I was unable to start tomcat successfully (when its killed). On investigating the Monit logs I found the following message:

[UTC Dec 24 12:08:23] error    : 'tomcat' failed, cannot open a connection to INET[] via TCP
[UTC Dec 24 12:08:23] info     : 'tomcat' start: /etc/init.d/tomcat

Through above logs, I found Monit is trying to start tomcat automatically for every particular time (when it finds tomcat service was killed). However, some inner conflicts stops this!

Other Information:

Tomcat server is properly running by using the port 8080:

netstat -an | grep 8080
tcp6       0      0 :::8080                 :::*                    LISTEN     
tcp6       0      0         TIME_WAIT  

ps -ef|grep tomcat
root     16237     1  9 12:10 ?        00:00:37 /usr/lib/jvm/java-6-oracle/bin/java -Djava.util.logging.config.file=/usr/share/apache-tomcat-7.0.40/conf/ -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms1024m -Xmx1530m -XX:NewSize=512m -XX:MaxNewSize=1024m -XX:PermSize=512m -XX:MaxPermSize=1024m -Djava.endorsed.dirs=/usr/share/apache-tomcat-7.0.40/endorsed -classpath /usr/share/apache-tomcat-7.0.40/bin/bootstrap.jar:/usr/share/apache-tomcat-7.0.40/bin/tomcat-juli.jar -Dcatalina.base=/usr/share/apache-tomcat-7.0.40 -Dcatalina.home=/usr/share/apache-tomcat-7.0.40 org.apache.catalina.startup.Bootstrap start
root     16851 16847  0 12:17 ?        00:00:00 sh -c su root -c ps\ \-ef\|grep\ tomcat 2>&1 2>/dev/null
root     16852 16851  0 12:17 ?        00:00:00 su root -c ps -ef|grep tomcat
root     16853 16852  0 12:17 ?        00:00:00 bash -c ps -ef|grep tomcat
root     16855 16853  0 12:17 ?        00:00:00 grep tomcat

Adding preferIPv4Addresses and preferIPv4Stack in file:

JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms1024m -Xmx1530m
-XX:NewSize=512m -XX:MaxNewSize=1024m -XX:PermSize=512m -XX:MaxPermSize=1024m"

Monit log:

[UTC Dec 24 12:48:39] error    : 'tomcat' failed protocol test [HTTP] at INET[] via TCP -- HTTP: Error receiving data -- Resource temporarily unavailable

Can anyone please guide me on this?

Thank You.

share|improve this question
Are you sure Tomcat is listening on on your system ? Can you check this with netstat -an | grep 8080 ? – krisFR Dec 24 '13 at 12:21
Thanks for the reply. I have edited my question and provided the netstat output (under 'Other Information:') – Senthil Kumaran Dec 24 '13 at 12:25 seems that Tomcat has bound itself to an IPv6 address. telnet 8080 fails or not ? – krisFR Dec 24 '13 at 12:31
If you are not using IPv6 at all consider disabling it then restarting Tomcat.… – Gene Aug 25 '15 at 17:39

Seems that Tomcat binds itself to an ipv6 address for

You can try to use preferIPv4Stack=true and preferIPv4Addresses=true directives in Java options to bind to an ipv4 address

Edit Tomcat startup script and add the following :

share|improve this answer
Sorry, it doesnt works for me! I have editted the question with my results – Senthil Kumaran Dec 24 '13 at 12:49
Still does not work but not the same error message. So now what reports netstat -an | grep 8080 ? and telnet 8080 ? – krisFR Dec 24 '13 at 13:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.