victordobry
victordobry

Reputation: 3408

Unable to debug app remotely - port isn't accessible externally

I need to debug my app remotely, but I unable to do that, due to the following error:

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

I have:

  1. Java app running in Tomcat on a remote server (Debian)
  2. IntelliJ Idea running locally (Windows)

I came to the conclusion that cause of problem is that port 8000, used for remote debugging, is inaccessible via external ip, only via 'localhost'. Following are causes, why I think so:

A remote debug is working on an expected port:

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

I able to telnet to it via '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.

But unable to telnet via external 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

Here is output of 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

How can I fix this issue with 8000 port? Or maybe there is other cause to my main problem?

Upvotes: 4

Views: 2349

Answers (3)

MMKarami
MMKarami

Reputation: 1204

I had a same problem via Java 11 and address property such as these JVM arguments:

-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=6565

However my problem is solved by change value of address property like this sample:

-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=*:6565

Now 6565 port is accessible externally.

Upvotes: 1

This is the command that did the trick for me:

sudo ufw allow <debug_port>

Upvotes: 1

user2911978
user2911978

Reputation: 1

Try "iptables -F" which unblocks the firewalls

Upvotes: 0

Related Questions