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.
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:
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.
The important properties are:
- '
com.sun.management.jmxremote.portto expose remote JMX' - '
com.sun.management.jmxremote.rmi.portto keep RMI on a predictable port' - '
java.rmi.server.hostnameso 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:
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.
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.
Then start Spring Boot normally:
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.portandjava.rmi.server.hostnamefor predictable remote access. - Secure remote JMX carefully or prefer secured Actuator endpoints when JMX networking is too cumbersome.
Related reading
- How to achieve high availability in a Kafka Streams app during deployment?
- How to activate JMX on my JVM for access with jconsole?
- How to add a custom health check in spring boot health?
- How to add additional scrape config to Prometheus
- How to acknowledge current offset in spring kafka for manual commit
- How to add a dependency to a Spring Boot Jar in another project?
- How to add basic authentication for Tensorflow serving
- How to add flag to Kubernetes controller manager

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack 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.