Spring Boot
JMX
Remote Access
Java
Application Monitoring

How to access Spring-boot JMX remotely

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Introduction

Spring Boot can expose application and actuator MBeans over JMX, but remote access is not enabled by a Spring property alone. There are two separate layers to understand: Spring Boot decides which MBeans exist, and the JVM decides whether a remote JMX connector is available so tools such as JConsole or VisualVM can connect from another machine.

That means “access Spring Boot JMX remotely” is really a combination of Spring Boot configuration and JVM startup flags.

Enable JMX MBeans in Spring Boot

Spring Boot can register MBeans for its own components and, if you use Actuator, for management endpoints as well.

In application.properties:

properties
spring.jmx.enabled=true
management.endpoints.jmx.exposure.include=health,info,metrics

This makes the relevant MBeans available inside the JVM. It does not, by itself, open a remote network port.

Enable the JVM Remote JMX Connector

To connect from another machine, start the JVM with remote JMX properties.

bash
1java \
2  -Dcom.sun.management.jmxremote=true \
3  -Dcom.sun.management.jmxremote.port=9010 \
4  -Dcom.sun.management.jmxremote.rmi.port=9010 \
5  -Djava.rmi.server.hostname=203.0.113.10 \
6  -Dcom.sun.management.jmxremote.authenticate=true \
7  -Dcom.sun.management.jmxremote.ssl=true \
8  -jar app.jar

The important properties are:

  • 'com.sun.management.jmxremote.port to expose remote JMX'
  • 'com.sun.management.jmxremote.rmi.port to keep RMI on a predictable port'
  • 'java.rmi.server.hostname so remote clients receive the correct host address'

Without the explicit RMI port and hostname, JMX often works locally but fails across hosts, containers, or firewalls.

A Simpler Development Setup

For local development or short-lived testing, people sometimes disable authentication and SSL:

bash
1java \
2  -Dcom.sun.management.jmxremote=true \
3  -Dcom.sun.management.jmxremote.port=9010 \
4  -Dcom.sun.management.jmxremote.rmi.port=9010 \
5  -Djava.rmi.server.hostname=127.0.0.1 \
6  -Dcom.sun.management.jmxremote.authenticate=false \
7  -Dcom.sun.management.jmxremote.ssl=false \
8  -jar app.jar

This is convenient for a private machine, but it is not appropriate for an exposed production service. Remote JMX without proper security is dangerous.

Connect with JConsole or VisualVM

Once the application is running with remote JMX enabled, connect using a JMX client such as JConsole.

bash
jconsole server.example.com:9010

If authentication is enabled, the client will prompt for credentials based on your configured JMX access and password files.

After connection, you should see Spring Boot MBeans under domains such as org.springframework.boot.

Security and Deployment Notes

For a real deployment, remote JMX should be treated as an administrative interface. That means:

  • restrict access with firewalls or private networking
  • enable authentication
  • enable SSL or tunnel the connection through a secure channel
  • avoid exposing the port directly to the public internet

In containerized or cloud deployments, Actuator HTTP endpoints are often easier to secure and operate than remote JMX. JMX is still useful, but it requires more care because of RMI networking details.

Example with Environment Variables

Many deployments inject the JVM properties through JAVA_TOOL_OPTIONS or a startup script.

bash
1export JAVA_TOOL_OPTIONS="
2-Dcom.sun.management.jmxremote=true
3-Dcom.sun.management.jmxremote.port=9010
4-Dcom.sun.management.jmxremote.rmi.port=9010
5-Djava.rmi.server.hostname=203.0.113.10
6-Dcom.sun.management.jmxremote.authenticate=true
7-Dcom.sun.management.jmxremote.ssl=true
8"

Then start Spring Boot normally:

bash
java -jar app.jar

This is often cleaner than hardcoding long JVM arguments in deployment definitions.

Common Pitfalls

The biggest mistake is enabling spring.jmx.enabled=true and expecting remote access to work automatically. That only controls whether Spring registers MBeans.

Another common issue is forgetting java.rmi.server.hostname. When the server advertises the wrong address, remote clients connect to the registry port and then fail on the follow-up RMI connection.

People also omit com.sun.management.jmxremote.rmi.port, which allows the JVM to choose a random RMI port. That usually breaks connections through firewalls and load balancers.

Finally, disabling authentication and SSL on an exposed environment is a serious security risk. If you need remote visibility and you do not want to manage secure JMX, Spring Boot Actuator over HTTPS may be a better operational choice.

Summary

  • Spring Boot JMX exposure and JVM remote JMX access are separate concerns.
  • Enable Spring MBeans with spring.jmx.enabled=true.
  • Enable remote connections with JVM flags such as com.sun.management.jmxremote.port.
  • Set both com.sun.management.jmxremote.rmi.port and java.rmi.server.hostname for predictable remote access.
  • Secure remote JMX carefully or prefer secured Actuator endpoints when JMX networking is too cumbersome.

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.