If you develop Android apps, you might get into problems when trying to debug through WIFI and get that dreadful message.
unable to connect to 192.168.1.xxx:5555: cannot connect to 192.168.1.xxx:5555 A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060)
Network stuff is tricky because it’s difficult to debug and once you’ve resolved the problem thanks to any web post, you forget again until the next time.
That’s why, I’m going to list here common causes and possible solutions. You will have found some of them in other sites because they are really common ones, and other problems are not that common, so you will spend more time debugging it… unless you remember this.
1. Check again the IP address (yes)
Sometimes, you are so sure your device’s IP address is forever and… no, it is not… Sometimes, you are continuously writing it wrong in the console.
2. Try to connect first through USB
- Connect via USB.
- Open console and type “adb kill-server && adb tcpip 5555”
- Disconnect the USB.
- Type in the console the “adb connect YOUR.ANDROID.IP.ADDRESS:5555”
- Check if it worked
3. Check if you have installed a firewall app
If you try to ping your device and cannot, it’s there a probability (because it happened to me the day I decided to write this post) you have an app like “Android Firewall” (pretty useful, BTW) and you’ve made the wrong configuration. In most firewall apps, you can configure by:
- whitelist: you block every connection except the ones made apps contained in that list.
- blacklist: you allow every connection except the ones made by the apps contained in that list.
If you do this only with installed apps, you’ll probably won’t have problems. If you are like me and want to have controlled everything, you’ll have a whitelist and restrict system apps…
Once I faced this problem, I started tweaking the setting and discovered:
- If you want to ping, you need to whitelist (or not blacklist) the item “Linux kernel”
- If you want to connect to adb via wifi, you need to whitelist (or not blacklist) the item “Linux shell”.
- If you want to use Internet in your developed app, you need to whitelist it.