Reputation: 293
I'm using Android Studio v1.0.1 to build an app in macOS Yosemite 10.10. When I try to debug the app, it installs correctly but has the error
Error running [app]: Unable to open debugger port : java.net.ConnectException "Connection refused"
When I run the DDMS, it shows the connected devices and the process. The trouble occurs just when trying to debug in Android Studio.
In other forums, I've found that something could have changed the port of the debugger, but that doesn't solve my issue.
Upvotes: 23
Views: 66513
Reputation: 31
I encountered same issue when running application on a physical device.
Just connect your PC and mobile to the same WiFi Network and disable the firewall of your PC. It worked for me.
Upvotes: 0
Reputation: 919
I my case mackbookpro: 20:21 Can't bind to local 8600 for debugger
I find /ect/hosts file is blank. so,I add the default hosts config to /etc/hosts file, It works fine.
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
Upvotes: 1
Reputation: 181
For Windows user you can kill the port by using the following command ..
Step 1:
Open the cmd (note: you may need to run it as an administrator, but this isn't always necessary), then run the below command:
netstat -ano | findstr :PORT_NUMBER
Step 2:
Syntax:
taskkill /PID PORT_NUMBER /F
cmd:
taskkill /PID 5005 /F
Upvotes: 1
Reputation: 131
It was a /etc/hosts file issue for me as well, I changed the following line (dont know why it was working before ... after upgrade to studio 3.1.3 it stopped working though!)
127.0.1.1 localhost
to
127.0.0.1 localhost
Upvotes: 2
Reputation:
I also solved this by making 127.0.0.1 in my Mac hosts file NOT point to a custom domain. One thing to note, I had 2 host files, one in "/" and one "/etc". One in "/etc" was actually used.
Upvotes: 0
Reputation: 13
For me none of the above solved and got stuck in this for months until I figured this solution. I had a modified version of my HOST file in my mac machine like pointing the IP 127.0.0.1 to a custom domain like www.mymac.com. Once I reverted that then I am able to debug. Yes!!! hope this helps for some one.
Upvotes: 1
Reputation: 1052
I had this problem when I was using a real device, I just unplugged the USB cable and then again plugged it in and it worked. In case of emulators, I guess restarting the emulator will work. This works because disconnecting the device/emulator closes all connected processes, and then you start your required process.
Upvotes: 3
Reputation: 9697
My problem Solved by below steps:
1. Invalidate Caches/Restart Android studio
2. Restart you Emulator.
Done for me.
Upvotes: 9
Reputation: 13558
Your debug port is probably busy (in use by another process). You can kill all the process associated with the ADB debug port (8601 or higher) using this:
fuser -k 8601/tcp
UPDATE:
Under OSX, lsof
should do the job in substitution of fuser
:
lsof -i :8601
Upvotes: 24
Reputation: 711
I have also met this problem. and I think the my solution may help others, so I post it here.
First, you should know what will cause "connection refused" problem. Usually there are two possible reasons:
As for your problem, I suggest you to first start your Android Device Monitor(DDMS) from your android studio, and DO NOT CLOSE IT.
Then in the DDMS, you can select the package you want to debug and "Update Threads", and now you can debug this application in your studio.
Upvotes: 15
Reputation: 647
You can use netstat
utility to see what is listening on what ports and, if you are quick, what tries to connect to what ports. This will help to to ensure that you have your process listening on a debugging port and confirm its number.
Upvotes: 0