My Tomcat 7 process, which I run on a server on Amazon EC2, has settings such as these in CATALINA_OPTS which should allow me to connect for JMX monitoring remotely:


However, connecting remotely does not work with either jconsole or jvisualvm. It just times out.

I've triple-checked that the EC2 security group allows access to the JMX remote port from my IP (and only from my IP).

Are there any settings missing?


Specify the java.rmi.server.hostname option too, so that it points to the public DNS name of your EC2 server:


That was sufficient to get it working for me, but for more tips, try this blog post:
JMX Monitoring on Amazon EC2


Here is more complete explanation of how to do it without messing with the group security (aka firewall):

Server side:

  1. download http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.23/bin/extras/catalina-jmx-remote.jar and put it in tomcat/lib
  2. add following listener to server.xml:

    <listener classname="org.apache.catalina.mbeans.JmxRemoteLifecycleListener"
        uselocalports="true" />
  3. add following settings in tomcat/bin/setenv.sh:

CATALINA_OPTS="-Dcom.sun.management.jmxremote \
 -Dcom.sun.management.jmxremote.ssl=false \

Restart tomcat

Client side:

  1. download same catalina-jmx-remote.jar and put it in JDK/JRE/lib/ext (same file as downloaded at Server step 1)
  2. start ssh tunnel with:

    ssh user@aws-host -L10001: -L10002:

  3. Start JConsole and enter the following remote service URL:


You have JConsole connected over SSH to your tomcat running on AWS.

As posted on: http://www.cod.ro/2012/08/monitoring-tomcat-7-on-rhel-aws-using.html


If you're having trouble setting the correct hostname for java.rmi.server.hostname try the following:

-Djava.rmi.server.hostname=$(/usr/bin/curl -s --connect-timeout 2 instance-data.ec2.internal/latest/meta-data/public-hostname)

This is convenient to use in an Elastic Beanstalk environment where instances will come and go.


I also tried using the JmxRemoteLifecycleListener and it didn't work for me.

This is what it worked for me:

  1. I choose 1005 as JMX port and my setenve.sh is like:

    CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=10005 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.local.only=false -Djava.rmi.server.hostname=localhost"
  2. Redirect using SSH the JMX port and the RMI

  3. Run visualvm using the following URI:


If you need more information have a look to this post: http://ignaciosuay.com/how-to-connect-a-java-profiler-like-visualvm-or-jconsole-to-a-remote-tomcat-running-on-amazon-ec2/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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