Home > database >  configure default command line arguments for remote debugging in IntelliJ
configure default command line arguments for remote debugging in IntelliJ

Time:09-27

when debugging a Run Configuration of Type "Spring Boot" in IntelliJ, the JVM is started with the following command line arguments: -agentlib:jdwp=transport=dt_socket,address=*:12345,suspend=y,server=y

how can i change these values?

more details

i am running a Maven-based Spring Boot application in IntelliJ and WSL2. When i try to debug the Run Configuration of Type "Spring Boot", the jvm never gets past this line: Listening for transport dt_socket at address: 12345 i think it is related to the fact that WSL2 is running in a sort of virtual machine, while IntelliJ is running in Windows.

my current workaround right now is to add a modified version of -agentlib command line argument to my JVM options and attach the debugger manually after running the Run Configuration. the only modification i do is changing address=*:12345 to address=12345 my understanding is that my modification causes the agent to listen on localhost:12345 and the debugger to connect to localhost:12345. And everything works because Windows and WSL2 somehow share localhost.

how did i find the workaround?

Fortunately you can see the command line arguments used by IntelliJ when running applications. The command line arguments for some of my projects is different. Sometimes it is address=*:12345 and sometimes address=12345.

UPDATE 2021-09-18 18:45

it looks like my problem is related to ipv6 vs ipv4. my workaround causes the jvm to listen on 127.0.0.1:12345, where without the workaround it uses ipv6.

enter image description here

UPDATE 2021-09-19 14:00

for now i settled with a new workaround suggested by Andrey in his comment. Adding -Djava.net.preferIPv4Stack=true to command line arguments makes the JVM use IPv4. Keep attention to preferIPv4Stack vs preferIPv6Stack, when reading Andreys comment ;)

CodePudding user response:

Add -Djava.net.preferIPv4Stack=true and -Djava.net.preferIPv6Addresses=false into Help | Edit Custom VM Options file and restart IDE.

  • Related