Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to open debugger port through IntelliJ

I've got a server running on DigitalOcean and a JAR file that I want to debug. I first start the JAR on the remote server using

java -jar Server.jar -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005

but on the console I see no output like "listening on port 5005...".

When I press debug in IntelliJ it says

unable to open debugger port (198.xxx.xxx.xx:5005): java.net.ConnectException "Connection refused"

This is my IntelliJ configuration:
enter image description here

I also tried using -Xdebug but it still didn't work.

If I set suspend=y it should wait until a debugger is connected, but instead, it starts without problems.

like image 976
Leonardo Avatar asked Nov 13 '16 16:11

Leonardo


People also ask

Why my debugger is not working in IntelliJ?

To solve this, simply remove the jar of the debugged module from all modules' dependencies in the Project Structure. If you do not know which modules have the debugged module jar as dependencies, you can use some tools (Eg. Sublime Text, bash, ...) to search for the module name which is stored in Intellij *.

How do I enable a debug port?

In the Integration Nodes view in the IBM Integration Toolkit, right-click the integration server with which you want to work, and click Launch Debugger. Click Configure, and enter a port number. Click OK to enable debugging on the selected port, and attach the debugger to the selected integration server.

How do I change the debugging port in IntelliJ?

Press Ctrl+Alt+S to open the IDE settings and select Build, Execution, Deployment | Debugger. In the Built-in server area, specify the port where the built-in web server runs. By default this port is set to the default IntelliJ IDEA port 63342 through which IntelliJ IDEA accepts connections from services.


2 Answers

The command to start the remote Java process in debug mode looks correct. If you don't see "Listening to Port blah" when you start the server JAR, then it might mean that the debug args are not being picked up. Another way to quickly check this would be to test with a telnet localhost 5005 on the machine where the server JAR is being executed. The telnet will fail if that port is not being used.

I suggest that you try the following, since the order of the parameters might be significant (I'll add some official evidence for this later):

java "agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005" -jar Server.jar
like image 118
Ashutosh Jindal Avatar answered Sep 19 '22 22:09

Ashutosh Jindal


this command worked for me:

export JAVA_OPTS='-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5005'

by default idea remote dialog suggest:

'agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005'

change it to:

'agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5005'

and issues port 5005.

like image 21
suifengpiao14 Avatar answered Sep 19 '22 22:09

suifengpiao14