Timeout Error when connecting localhost api with Android Studio on Real devices through USB

后端 未结 3 808
我寻月下人不归
我寻月下人不归 2021-01-11 17:32

I am using Android Studio version 3 on Window 8.1. There is XAMPP installed to host php api on localhost. I am trying to access the localhost api from Android Studio.

<
3条回答
  •  梦毁少年i
    2021-01-11 18:09

    Your Network firewall Blocks the connection to localhost. To resolve this you can do :

    In windows

    1st Method Add Inbound rule (Recommended)

    • Create a new inbound rule with Windows Firewall with Advanced Security. The type in this case would be port, then on the next page you enter 8080 as the port. On the next page select either "Allow the connection", or "Allow the connection if it is secure". Select when the rule applies, and finally give the rule a name.

    • Connect the localhost api through the new allowed port.

    • Use ip-address of the localhost instead of localhost.

    2nd Method Turn of firewall.

    In Linux

    1. Add IPTable Entry

    • You can learn adding incoming and outgoing rules using ssh and http in Linux here

提交回复
热议问题