How to connect emulator to laravel server localhost:8000

南楼画角 提交于 2019-12-12 03:15:00

问题


I can connect to localhost:8080 when my android app connect to my project in wampserver with 10.0.0.2:8080,but i use laravel and my web service is in localhost:8000. i want to connect from emulator to my web service in laravel server in IP 10.0.0.2:8000 but i can't connect to it.

failed to connect to /10.0.2.2 (port 8000) after 10000 ms . i tried localhost:8000 and some other IP, which IP use to connect to laravel server?


回答1:


a bit late but your issue has to do with your routing. First of all assuming you are on windows go to your hosts file and map the IP: 10.0.2.2 to 127.0.0.1

Like so:

127.0.0.1    10.0.2.2

Then if you've configured your virtual hosts map the IP 10.0.2.2 to your project directory in your httpd-vhosts.conf

Like this:

<VirtualHost *:80>
    DocumentRoot "C:/www/example/"
    ServerName 10.0.0.2
    ServerAlias 10.0.0.2
</VirtualHost>


来源:https://stackoverflow.com/questions/34474673/how-to-connect-emulator-to-laravel-server-localhost8000

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