无法远程调试应用程序 - 无法从外部访问端口

时间:2015-12-27 11:41:04

标签: java linux tomcat intellij-idea remote-debugging

我需要远程调试我的应用,但由于以下错误,我无法执行此操作:

Unable to open debugger port (X.X.X.X:8000): java.net.ConnectException "Connection timed out: connect"

我有:

  1. 在远程服务器(Debian)上的Tomcat中运行的Java应用程序
  2. 本地运行的IntelliJ Idea(Windows)
  3. 我得出结论,问题的原因是用于远程调试的端口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'telnet到它:

    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端口解决此问题?或者我的主要问题还有其他原因吗?

2 个答案:

答案 0 :(得分:0)

尝试使用“ iptables -F”来解锁防火墙

答案 1 :(得分:0)

这是对我有用的命令:

sudo ufw allow <debug_port>

相关问题