Unable to establish debug connection to localhost | Community
Skip to main content
April 19, 2022
Solved

Unable to establish debug connection to localhost

  • April 19, 2022
  • 5 replies
  • 3862 views

Hi,

I have installed crx-quickstart.jar in my local. localhost:4502/aem/start.html is up and running.

When i try to connect to the server in the debug mode from eclipse, it throws following error:

could not establish debug connection to localhost : 30303
Failed to connect to remote VM. Connection refused.
Connection refused: connect

Eclipse is running in AEM Perspective 

When I connect to server in run mode it's all good.

Connection Details:

Port: 4502

DebugPort: 30303

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Anish-Sinha

Hi @schallag ,

Start your AEM instance using command-prompt/terminal using below command 

java -Xmx512m -agentlib:jdwp=transport=dt_socket,address=30303,server=y,suspend=n -jar cq-author-p4502.jar -Dsling.run.modes=author -nofork

Once the server is up then try to connect to the port 30303 and it will connect.

5 replies

Anish-Sinha
Adobe Employee
Anish-SinhaAdobe EmployeeAccepted solution
Adobe Employee
April 19, 2022

Hi @schallag ,

Start your AEM instance using command-prompt/terminal using below command 

java -Xmx512m -agentlib:jdwp=transport=dt_socket,address=30303,server=y,suspend=n -jar cq-author-p4502.jar -Dsling.run.modes=author -nofork

Once the server is up then try to connect to the port 30303 and it will connect.

schallagAuthor
April 20, 2022

Thank you. It worked.

Ritesh_Mittal
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
April 19, 2022

Hi @schallag ,

 

You can either enable debug mode from the command prompt while running the JAR or change the JVM opts in the start batch file. Both options have been described below-

 

https://rashidjorvee.blogspot.com/2018/12/how-to-start-aem-in-debug-mode.html

https://experienceleague.adobe.com/docs/experience-cloud-kcs/kbarticles/KA-17459.html?lang=en

schallagAuthor
April 20, 2022

Thank You

DEBAL_DAS
April 20, 2022

Please refer the below details and update the port number as per your need -

 

Go to bin folder in crx-quickstart and change the line 25 in start.bat by adding the highlighted part here (address port number can be any number of your choice)

if not defined CQ_JVM_OPTS set CQ_JVM_OPTS=-Xmx1024m -XX:MaxPermSize=256M -Djava.awt.headless=true -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=10123

Change line no. 44 by adding this

set CQ_RUNMODE=%CQ_RUNMODE%,crx3,crx3tar,debug

Save the file.

Once saved open the command prompt, go to \crx-quickstart\bin and type “start.bat”, once it’s done you’ll see another window of cmd being opened and the server will start in debug mode as seen below

 

Check if the server is started or not by opening localhost:4502 in the browser

Setting up the debug config in eclipse

Go to Run -> Debug Configurations -> Remote Java Application

Set up a new configuration like seen below by selecting the project (mostly it’ll be core) and click Debug

 

Check if Debug is working fine or not by having the Debug view

 

 

Eclipse by default will suspend execution on uncaught exceptions which will debug the code which we haven’t even selected. This will waste our time. So please do this to avoid it

Go to Windows - > Preferences -> Java -> Debug and uncheck “Suspend execution on uncaught exceptions”

 

Set debug points in your code and explore!

schallagAuthor
April 20, 2022

Thank You for the detail steps.

April 20, 2022

Hello,

Please try simple command while opening your AEM instace:

 

Java -jar <yourjarname-4502>.jar -debug <debugport> 

and when open the file from eclipse- ctrl+shift+R  - add debug points in file opened from as highlighted below,

open the java file from .core 

 

And you can see the threads running for debugging in debug perspective.

 

Please let me know if this helps.

Thanks!

 

schallagAuthor
April 20, 2022

Than You for the reply.

schallagAuthor
April 20, 2022

Hi , I tried what's mentioned here in the comments. I see the local host is up and running in Debug view. 

But when i click the debug button in Debug configurations, It throws the below error. Please Advice.