Unable to attach debugger in Android Studio - localhost:8600 java.net.ConnectException

Quite embarrassing, but it looks like some time ago I had entered an ip address into my /etc/hosts file to test something as localhost and never removed it. I found a comment on another post saying to check that the following is in your /etc/hosts:

127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost

Upon commenting out that spurious line, the debugger is now working. Given I have a dozen or so other IPs in that file (so I can more easily test remote hosts with a friendly name), I must have not noticed this one at the bottom. I think a more foolproof approach to verifying if this is the problem or not is to ping localhost and verify that it resolves to the ip address of 127.0.0.1, e.g.,

$ ping localhost
PING localhost (127.0.0.1): 56 data bytes

Great comments and suggestions from other folks here too, thanks!


I just experienced the same issue. It seems, as if Android Studio Version 2.2 has some issues with a non-attaching debugger as you can see for example here and here.

In my case the following helped:

  • Remove the launch profile for your app by going to Run -> Edit Configurations... and removing the profile there. Don't forget to hit the OK button after you have removed the profile. :)
  • Create a new launch profile from scratch by again going to Run -> Edit Configurations..., hitting the + button, selecting an Android App launch profile and selecting your start module. The other default values of the profile were just fine.

Hope this helps you as well.


I am using a real device. Simply deleting the app on the device, and then running from Android Studio solved this issue.

It seems Android Studio had trouble with overwriting the file that was already on the phone.