Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse Error: "Failed to connect to remote VM"

Tags:

java

eclipse

People also ask

How do I fix failed to connect to remote VM Connection refused in Eclipse?

1- Open Windows Firewall by clicking the Start button Picture of the Start button, and then clicking Control Panel. In the search box, type firewall, and then click Windows Firewall. 2- Click Turn Windows Firewall on or off.

How do I fix resolve failed to connect to remote VM connection refused?

Just restart the Java application in debug mode. One of the human error which causes "Failed to connect to remote VM. Connection refused". Some time typo on hostname or port causes Eclipse trying to connect different servers or a different port, which is an obvious reason you get this error.

How do I enable remote debugging in STS?

Running a remote debugging session from STS/EclipseCreate a new Remote Java Application Debug Configuration; Select source code project for the service under Project. Specify the debugger port defined above under Connection Properties.


Have you setup the remote VM to accept connections?

java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=10000,suspend=n yourServer

Is there a firewall in the way?

Are you specifying the correct host / port?

Are you connected to a VPN?


Remove your proxy from eclipse!

Go to network Connections within General Preferences ( Windows -> Preferences ) and set "Active Provider" to "Direct"

remove proxy

Reboot your Eclipse after that


Use 0.0.0.0 for addresses to be able to connect form any remote machine i.e.:

-Xdebug -Xrunjdwp:transport=dt_socket,address=0.0.0.0:8000,server=y,suspend=y

David Citron is right -- if localhost is not resolving properly, it can cause this problem. Here's how to test:

If it works when your PC is not connected to the net (no WiFi, no network cables). If it does work under those conditions, then it may be that you need to make sure that addresses are resolving to localhost properly. The messages that DDMS and adb.exe use for debugging and communicating to the VM must properly resolve to localhost on your PC. (Yes, it's odd that other commands using DDMS & adb work just fine but debugging doesn't. Seems that something in DDMS or adb needs to be standardized so they all work under the same conditions.)

If you need to make sure that things are resolving to localhost properly:

1) Make sure that this line is in your /Windows/System32/drivers/etc/hosts file:

127.0.0.1  localhost

(you can have any amount of whitespace between "127.0.0.1" and "localhost")

And -- as David Citron suggested -- make sure that the hosts file is valid and doesn't have cruft or errors in it.

2) If that doesn't work, then you may need to also add your PC's IPv4 address to the hosts file, and resolve it to localhost. (You can find out the IPv4 address for your machine with the ipconfig command.) If, for example, your machine's IPv4 address is 192.168.1.100 then you'd add the line

192.168.1.100  localhost

to your hosts file. (You can add it below the "127.0.0.1 localhost" line in the file.)

You can verify that adb (and your emulator if you're running one) is listening on ports by using the netstat -b command. (Note that you need admin privileges for the -b option. I open a command window using "Run as Administrator.")


Our development image only has the Tomcat service installation on it, so setting the environment variables, etc., didn't have any effect. If you need to do this through the Tomcat Windows service, there are a few things you'll need to be aware of:

  • David Citron's comment was the last bit that I needed to get my connection working. The hosts file on our machines has localhost commented out (it's supposedly resolved through the DNS, but that doesn't work for the debug connection). I uncommented it and was able to connect.
  • If user access control is turned on, you'll need to use your admin credentials to access the services control panel or the Tomcat monitor app or whatever you're using to toggle the server state. The monitor app (documented here) is probably the best, because you can both edit the server settings for the debug options and start and stop the server.
  • I thought that perhaps you would need to run Eclipse as an administrator to be able to terminate the Tomcat process, but you don't. Once you have that remote attachment, you're able to work with the service up to termination.