问题
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