Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remote debug ec2 java instance

My application is running in EC2 as a docker with java application. I'm exposing 5005 port for debug, and locally it works perfectly. However on EC2 environment I get java.net.ConnectException "Connection refused (Connection refused)" when trying to connect using Intelij.

  • Security group is set to open ports 80, 5005, 22
  • Docker is exposing port 80 and 5005
  • Application is running with java args -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=5005,suspend=n

Am I missing something ?

like image 902
Maciej Rudnicki Avatar asked Nov 18 '22 08:11

Maciej Rudnicki


1 Answers

For those who are still interested, here is a way how to create a Remote JVM Debug on EC2 with docker

  1. On the yaml file add the 'port' attribute.
 ports:
     - "5005:5005"
  1. To the dockerfile run the Jar with the following command
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
  1. On the inbound role on the EC2:
Cutsom TCP => 5005 => Your IP
  1. In the Intellij create Remote JVM debug
    • In the host enter the host ip
    • Port: 5005
    • Choose JDK 9 or later as the address should be with *:5005
  2. Click the Debug Button and it should work
like image 172
Ron Shoshani Avatar answered Mar 15 '23 02:03

Ron Shoshani