javaandroid-studioretrofit2httpconnection

failed to connect to port80 after 100000ms in android


I am hitting otp api's from Emulator its work but if I am using real device then getting failed to http connecting error found. 2020-11-06 13:33:23.603 24840-24840/a3.amp35.in E/Genrate: failed to connect to /192.168.132.101 (port 80) from /26.81.35.26 (port 39596) after 100000ms need help


Solution

  • Your device is outside of your local network. Api is on 192.168.132.101 while device is out given net 26.81.35.26

    Either expose your API to the outside world (eg. port forward it or host in on globally accessible device) or connect your device to your local network (eg, use the same WIFI, or via VPN)

    Also firewall settings on the 192.168.132.101 might block the incoming connections from different subnets.

    And probably many more possible causes...