idea远程调试"Connection refused: connect"踩坑

在本机进行开发用tomcat部署时我们可能会在tomcat/bin/catalina.sh配置如下debug参数进行调试:

JAVA_OPT="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8888"

但是在远程服务器上同样的配置却在启动调试时报错:

Unable to open debugger port : java.net.ConnectException "Connection refused: connect"

检查Remote配置:
idea远程调试
IP和端口号都没问题但是"Connection refused",于是我们检查服务器16808端口情况:

use:~/tomcat/logs # netstat -an|grep 16808
cp        0      0 127.0.0.1:16808          0.0.0.0:*               LISTEN

可见当前16808端口服务被绑定了回环地址,外部无法访问,说明JAVA_OPT里address如果不指定ip会默认绑定到本机,如果是要提供远程调试的服务器上的工程,就需要指定当前服务器地址才行,即:

JAVA_OPT="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=‘服务器IP地址’:8888"

问题于是解决。

原贴链接:https://www.jianshu.com/p/aa63146d7e0b

你可能感兴趣的:(idea远程调试"Connection refused: connect"踩坑)