java.net.ConnectException: /127.0.0.1:8080 an android emulator

前端 未结 1 501
一整个雨季
一整个雨季 2020-12-06 18:18

String url = \"http://127.0.0.1:8080/SampleServlet/TestServlet?\"; URL url = new URL(con_url);

run in android emualator. but i got the connectexception 02-20 13:05:

相关标签:
1条回答
  • 2020-12-06 18:56

    127.0.0.1 is a Android emulated device's own loopback interface.

    In other words, you connect to android emulated device (not to your computer) by using 127.0.0.1.

    To get connection to your machine with web-server use 10.0.2.2 or real machine IP address (if you have direct access from web).

    Use command ipconfig(Windows)/ifconfig(Linux) to obtain your IP address.

    Also see official docs or this!

    0 讨论(0)
提交回复
热议问题