Remote Debugging - Unable to connect to the localhost:8080

Answered

Tomcat with Nginx (proxy server) running on a DigitalOcean Droplet. Running it in Debug mode, fails to connect (see message below), however, clicking 'Test SFTP Connection' Button is a success.

Error Running Remote: Unable to connect to the localhost:8080

Run Configuration Settings.

Open Browser:

http://localhost:8080/

Tomcat Server Settings

Type: sftp
Host: example
Path from root: /opt/tomcat/webapps/explodedWar
Mapped as: left blank

Remote Connection Settings
Host: localhost
Port: 8080

0
15 comments

Change Remote Connection Settings | Port to 80? Why do you use different ports in the URL and connection settings?

0
Avatar
Permanently deleted user

That was a typo. See update

0

Does `telnet localhost 8080` work from the machine where you run IntelliJ IDEA?

0
Avatar
Permanently deleted user

No.

 

telnet localhost 8080
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying fe80::1...
telnet: connect to address fe80::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host

0

How do you expect debugging and connection to work if the specified host/port cannot be connected? This issue is not with IntelliJ IDEA.

0

Once you open the ports used for debugging and confirm it works using telnet, it will also work from IntelliJ IDEA.

0
Avatar
Permanently deleted user

The only way to 'telnet 8080' is to start tomcat in the local machine, which i have done.

I then try to start the remote debugger but this gives the following:

Unable to open debugger port (localhost:49427): java.net.ConnectException "Connection refused"

 

0

Tomcat must be started in debug mode and instructed in IntelliJ IDEA Remote Run/Debug configuration:

0
Avatar
Permanently deleted user

Error running Remote: Unable to open debugger port (localhost:62587): java.net.ConnectException "Connection refused"

 

Parameters:

-agentlib:jdwp=transport=dt_socket,address=62587,suspend=n,server=y -javaagent:/Users/UserOne/Library/Caches/IntelliJIdea2017.1/groovyHotSwap/gragent.jar

0

Can you telnet to port 62587 when the server is started? If not, it's also probably blocked by your firewall or the options were specified in the wrong place and are not affecting your Tomcat.

0
Avatar
Permanently deleted user

Local Machine has no firewall (mac's firewall is off).  

Local Machine: lsof -n -i:62587 | grep LISTEN (has not listeners)

 

Server: sudo netstat -lnp | grep 62587

tcp        0      0 0.0.0.0:62587           0.0.0.0:*               LISTEN      27533/java

 

Server Firewall has port 62587 enabled:

OpenSSH ALLOW Anywhere
Nginx Full ALLOW Anywhere
8080 ALLOW Anywhere
62587/tcp ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
Nginx Full (v6) ALLOW Anywhere (v6)
7474 (v6) ALLOW Anywhere (v6)
62587 (v6) ALLOW Anywhere (v6)

 

Added '' JAVA_OPTS="-agentlib:jdwp=transport=dt_socket,address=62587,suspend=n,server=y" " to setenv.sh  on server.

ps command on local machine shows these options.

ps ax | grep tomcat

/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/bin/jdb -Djava.util.logging.config.file=/usr/local/Cellar/tomcat/8.5.15/libexec/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -classpath /usr/local/Cellar/tomcat/8.5.15/libexec/bin/bootstrap.jar:/usr/local/Cellar/tomcat/8.5.15/libexec/bin/tomcat-juli.jar -sourcepath /usr/local/Cellar/tomcat/8.5.15/libexec/../../java -Dcatalina.base=/usr/local/Cellar/tomcat/8.5.15/libexec -Dcatalina.home=/usr/local/Cellar/tomcat/8.5.15/libexec -Djava.io.tmpdir=/usr/local/Cellar/tomcat/8.5.15/libexec/temp org.apache.catalina.startup.Bootstrap -agentlib:jdwp=transport=dt_socket,address=62587,suspend=n,server=y start

 

 

0

If Tomcat is not running on the same machine where you run IntelliJ IDEA, you should specify the actual remote server host in the run/debug configuration, not `localhost`. IntelliJ IDEA doesn't do any SSH forwarding automatically. If remote server doesn't permit connection, you can set up tunnels for HTTP and debugger ports manually and in this case localhost will work via the tunnel.

0
Avatar
Permanently deleted user

Not sure what you mean. I have Tomcat running on both (local and server). I start tomcat on both machines then I use the remote server settings above to setup a Remote Tomcat instance with IntelliJ then click on 'Run > Debug ".

Do you have the link to the most current tutorial on how to setup a remote tomcat instance?

Thanks

0

You don't need local Tomcat running if you plan to debug remotely.

The guide at http://blog.trifork.com/2014/07/14/how-to-remotely-debug-application-running-on-tomcat-from-within-intellij-idea/ is pretty accurate.

0
Avatar
Permanently deleted user
0

Please sign in to leave a comment.