How can I access my localhost from my Android device?

前端 未结 30 2365
面向向阳花
面向向阳花 2020-11-21 05:53

I\'m able to access my laptop web server using the Android emulator, I\'m using 10.0.2.2:portno works well.

But when I connect my real Android phone, th

30条回答
  •  忘掉有多难
    2020-11-21 06:36

    This solution is usable when your mobile device and computer is not in same network:

    You need to use port forwarding in this case. In the Google chrome inspect window (chrome://inspect) You can see the connected devices.

    Click on the port fowading button, and set a random port say 3000 to the port which your laptop uses say 8080.

    now use localhost:3000 from device to access the localhost:8080(or_whatever_ip:portno) in the laptop. You can check it in the mobile browser. Try localhost:3000 in the mobile browser. Make sure to check the "Enable port forwarding" checkbox in the "Port forwarding settings" window

提交回复
热议问题