Problem
Running a Spring Boot application in IntelliJ IDEA 2025.2.2 using WSL2 fails due to a JMX communication error. The error reports a port being already in use, such as:
JMX connector server communication error: service:jmx:rmi://0.0.0.0:55875
jdk.internal.agent.AgentConfigurationError: java.rmi.server.ExportException: Port already in use: 55875
Cause
This issue arises because the JMX configuration is attempting to bind to ports that are either unavailable or already in use on the system. Incorrect or conflicting WSL2 configurations, particularly network settings, might contribute to this behavior.
Resolution
Suggested Fixes
-
Check and Kill Processes Using the Port:
Use the following commands within the WSL2 environment to identify and terminate processes using the conflicting port:
sudo lsof -i :55875 sudo kill -9 <PID> -
Modify WSL2 Configuration:
Adjust the
.wslconfigfile in the Windows user directory (C:\Users\<username>) by removing specific settings:
After editing the configuration file, shutdown the WSL2 instance using thenetworkingMode=mirrored hostAddressLoopback=truewsl --shutdowncommand. Then restart WSL2 and retry running the application.
Workaround Configuration
-
Modify the Spring Boot run configuration in IntelliJ IDEA to include the option:
"Disable JMX Endpoints". This avoids the JMX conflict, but some features may be limited. -
Update the JMX hostname configuration by replacing
localhostwith the reachable IP of the JMX server within WSL2.
Testing Suggestions
-
Try testing with a standard Spring Boot project like the Spring PetClinic to verify if the issue is specific to the project.
-
Ensure the issue reproduces consistently, and identify environmental factors (e.g., VPN use with specific WSL network configurations) influencing the behavior.
Comments
0 comments
Please sign in to leave a comment.