【发布时间】:2016-04-01 12:10:53
【问题描述】:
我需要远程调试我的应用,但由于以下错误,我无法这样做:
Unable to open debugger port (X.X.X.X:8000): java.net.ConnectException "Connection timed out: connect"
我有:
- 在远程服务器 (Debian) 上的 Tomcat 中运行的 Java 应用程序
- 在本地运行的 IntelliJ Idea (Windows)
我得出的结论是,问题的原因是 用于远程调试的端口 8000 无法通过外部 ip 访问,只能通过“localhost”访问。以下是原因,为什么我这么认为:
远程调试正在预期的端口上工作:
root@victor-app-server:/opt/tomcat-home/bin# netstat -tulpn | grep 8000
tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN 3773/java
我可以通过 'localhost' 远程登录到它:
root@victor-app-server:/opt/tomcat-home/bin# telnet localhost 8000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.
但无法通过外部 ip 远程登录:
root@victor-app-server:/opt/tomcat-home/bin# telnet X.X.X.X 8000
Trying X.X.X.X...
telnet: Unable to connect to remote host: Connection timed out
这是 iptables 的输出:
root@victor-app-server:/opt/tomcat-home/bin# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
如何解决 8000 端口的这个问题?或者也许我的主要问题还有其他原因?
【问题讨论】:
-
我假设你的 debian 服务器上的防火墙不允许连接到端口 8000。
-
@Heri,我认为由于 iptables 不包含规则,防火墙不会引起问题。如果不是这样,请解释一下,如何检查防火墙?
-
服务器在哪里?在局域网还是在外部?如果服务器在另一个局域网,服务器所连接的局域网中路由器的配置是否正确?
标签: java linux tomcat intellij-idea remote-debugging