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
Ngrok is the best solution.
If you're developing PHP then I recommend installing Laravel Valet, It has MacOS and Linux versions, then you may use valet share
command. If you're developing any frontend tech and need to share a port like 3000 then use ngrok directly ngrok http 3000
I used this process:
Note that this process requires you to change the WiFi settings on the Android device at the start and end of every session. I found this less painful then rooting my Android device.
On Windows PC You may not need to do anything else than finding out your IPv4 Address using "ipconfig" command.
Other Env Details : Windows 7, Google Nexus 4 (4.2.2), Tomcat Server, Grails Application.
You should also make sure that you have the permission to access internet in AndroidManifest file :
<uses-permission android:name="android.permission.INTERNET"/>
EASIEST way (this worked flawlessly for me) is to locally host your site at 0.0.0.0:<port_no>
and to access it using mobile devices, use <local_ipv4_address>:<port_no>/<path>
in browser.
ipconfig
in cmdA solution to connect my mobile device to my wamp server based on my laptop:
First, wifi is not a router. So to connect my mobile device to my wamp server based on localhost on my laptop, I need a router. I have downloaded and installed a free virtual router: https://virtualrouter.codeplex.com/
Configuring it is really simple:
Then you can connect to your laptop via your device by launching a browser and fill the IPV4 address of your laptop (to find it on windows, type in cmd : ipconfig, and find ipv4 address)
You should see your wamp server home page.
You may have your web server listening on your loopback interface and not on your network interface. Major signs of this are:
127.0.0.1
and localhost
(from localhost or Android emulator) work192.168.xxx.xxx
do not work, whether from localhost, LAN, or WANI talk more about diagnosing this and fixing this in an answer here.