Error running 'Remote Debugger': Unable to open debugger port (localhost:5005): java.net.ConnectException "Connection refused (Connection refused)"
Asked Answered
P

2

18

I am setting up remote debugger in IntelliJ on Mac. I followed the template without any modification. Then I click the "Debug xxx" button. It shows

"Error running 'Remote Debugger': Unable to open debugger port (localhost:5005): java.net.ConnectException "Connection refused (Connection refused)""

I checked the following:

  1. There is no port listening on 5005.
  2. The firewall is shut off entirely.
  3. I tried to ping localhost 5005 and the connection is refused.

I am confused. There is no firewall and no port listening. Why the connection is still refused?

Penult answered 15/11, 2018 at 20:50 Comment(10)
Remote debugger needs to connect to the JVM that is already running in debug mode. Make sure you start the app you want to debug first with the JVM options suggested by the IDE. Then start Remote configuration to connect and debug this app.Murdoch
did you try to use 127.0.0.1 instead of localhost? sometimes your localhost is not properly mapped to that address.Asbestos
To add to @Murdoch remarks (in case it helps), in my setup through Maven with pom.xml there is an XML attribute cargo.jvmargs - in here I had to append the commands that allow the app to start in debug mode -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000. Running then in Terminal sudo lsof -i :8000 confirmed that indeed port 8000 is open, and et violà, I could finally attach the debugger remotely in IntelliJ.Jericajericho
@Murdoch and what if it was just working couple of days ago and today it stopped without Mac being rebooted?Lamanna
@minerals Please post a question with the complete issue description to get help, comments to the other questions is not the best way to get help here.Murdoch
@Murdoch my situation and problem is identical to Jill's. I am using remote debugging in IntelliJ on a weekly basis but today it stopped working out of nowhere. nc -vz 127.0.0.1 5005 throws nc: connectx to 127.0.0.1 port 5005 (tcp) failed: Connection refused. It doesn't seem like you need a JVM running in debug mode or there is something else. In fact I did nothing to run it in debug mode before for remote debugging to work previously.Lamanna
You do need it, apps do not start in the debug mode automatically and do not listen on port 5005 without the debugger options.Murdoch
The app must be started by you with the options suggested by the IDE, IDE doesn't start the app with these options when you use remote debug.Murdoch
I just posted the answer that works on mac here: https://mcmap.net/q/326617/-unable-to-open-debugger-port-in-intellijSnider
Does this answer your question? Unable to open debugger port in IntelliJSnider
B
0

Remote debugger needs to connect to the JVM that is already running in debug mode. Make sure you start the app you want to debug first with the JVM options suggested by the IDE. Then start Remote configuration to connect and debug this app.

CrazyCoder's answer is correct. I just paste his answer here to appear it more

Bullwhip answered 21/12, 2023 at 11:26 Comment(0)
S
-4

when you run mvn spring-boot:run you need to add debug target to maven command make sure the address in the target matches the address in the remote config

Saunders answered 23/8, 2020 at 11:47 Comment(1)
Welcome to Stack Overflow. Before giving an answer make sure that your answer addresses the issue given in the question (refer also to the question tags at the end of question's description). In particular, the question is not related to spring-boot and it asks for answers using IntelliJ (how does when you run mvn spring-boot:run you need ... fit in that context?). – As you're starting out here, please take the tour to learn how Stack Overflow works and review How do I write a good answer?.Mandymandych

© 2022 - 2024 — McMap. All rights reserved.