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

前端 未结 11 2091
不思量自难忘°
不思量自难忘° 2021-02-07 00:35

I cannot attach the debugger in Android Studio while running debug on a phone.

I’m currently using a Samsung S4, running Android 4.4.4 (but have tried an S5, S6, S7, and

11条回答
  •  忘了有多久
    2021-02-07 01:34

    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!

提交回复
热议问题