Unable to open debugger port in IntelliJ IDEA

2020-05-13 07:04发布

I have a problem that I can not set up my application in debug mode with IntelliJ IDE, but run mode is OK.

My OS is Windows 7, IDE is IntelliJ IDEA, web container is Tomcat 6. I have tried for a long time, changed the HTTP port and the JMX port, but it did not work.

When I set up the app in debug mode with IntelliJ, it failed and the event log is:

16:05:35 Error running tomcat: Unable to open debugger port : java.net.BindException "Address already in use: JVM_Bind".

25条回答
forever°为你锁心
2楼-- · 2020-05-13 07:33
  1. Check "Run" configuration to see which port it is using (8081).
  2. Find all the other processes using that port lsof -t -i :8081
  3. Kill the processes on that port. kill PROCESS_ID
  4. Run Tomcat in Debug mode.

In my case, I wasted so much time on changing debugger port but it was not the issue. Since tomcat was not able to run on the port I chose in Run configuration, I was not able to debug my service.

查看更多
【Aperson】
3楼-- · 2020-05-13 07:33

My assumption that this exception usually occurs when Tomcat is improperly closed and still holding the ports. Usually it is enough to kill any process listening to 1099 port. For Window 10:

netstat -aon | find "1099"


taskkill /F /PID $processId
查看更多
Animai°情兽
4楼-- · 2020-05-13 07:34

the key to the issue is in debugger port. I was having the same problem, I was killing every process listening on port 8081 (my http port), 1099 (JMX port), tomcat shutdown port, every java.exe, and still nothing.

The thing is this debugger port is different. If you run the application, it will go through the port you have Tomcat configured for, 8080, 8081 or whatever. But if you run it in Debug mode, it goes through a different port.

If you go edit your Tomcat configuration from IntelliJ, the last tab is Startup/Connection. Here go see the configuration for Debug mode, and you'll see its port. Mine was 50473. I changed it to 50472, and everything started working again.

查看更多
何必那么认真
5楼-- · 2020-05-13 07:35

This happens when you have application running on the same port number. One way to do this by killing the process forcefully. Open command prompt as an admin. Run command 'taskkill /IM "java.exe" /F'. This worked for me in Windows. Let me know if this works.

查看更多
走好不送
6楼-- · 2020-05-13 07:36

try chmod a+x /path/to/tomcat/bin/catalina.sh if you run it in intelliJ

查看更多
Animai°情兽
7楼-- · 2020-05-13 07:38

If you're on windows you can bypass the socket issue completely by switching to shared memory debugging.

enter image description here

查看更多
登录 后发表回答