Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

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?

share|improve this question
up vote 2 down vote accepted

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

share|improve this answer

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

Server side:

  1. download 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/


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:

share|improve this answer

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.

share|improve this answer

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.