Android cannot access localhost?

倾然丶 夕夏残阳落幕 提交于 2019-12-07 00:39:21

问题


I started a local http server on Android and it can be reached by other computers in the same local network. But if I try to access this server using opera on the same phone, it won't work. So this means we are not able to access localhost on Android? Thanks!


回答1:


You shoud use next IP 10.0.2.2




回答2:


Just check this http://developer.android.com/guide/developing/devices/emulator.html#networkaddresses

If ur app running in localhost:3000, then try to use as 10.0.2.2:3000 in your android emulator




回答3:


Try to use your ip address in your pc (ipconfig to see the ip address for your pc)

IPv4 Address. . . . . . . . . . . : 192.168.1.12

So, use: 192.168.1.12:3000



来源:https://stackoverflow.com/questions/4529784/android-cannot-access-localhost

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!