How can I access my localhost from my Android device?
USB doesn't provide network to mobile device.
If both your desktop and phone are connected to the same WiFi (or any other local network), then use your desktop IP address assigned by the router (not localhost
and not 127.0.0.1
).
To find out the IP address of your desktop:
- type into the command line
ipconfig
(Windows) orifconfig
(Unix)- on Linux the one-liner
ifconfig | grep "inet " | grep -v 127.0.0.1
will yield only the important stuff - there's a bunch of suggestions on how to have a similar output on Windows
- on Linux the one-liner
- there's going to be a bunch of IP's
- try all of them (except the forementioned
localhost
and127.0.0.1
)
If your phone is connected to the mobile network, then things are going to be harder.
Either go hardcore:
- first find out your router external IP address (https://www.google.de/search?q=myip)
- then, on the router, forward some port to
<your desktop IP>:<server port number>
- finally use the external IP address and forwarded port
Otherwise use something like xip.io or ngrok.
NOTE: The ifconfig
command has been deprecated and thus missing by default on Debian Linux, starting from Debian stretch. The new and recommended alternative for examining a network configuration on Debian Linux is ip command. For example to use ip command to display a network configuration run the following:
ip address
The above ip command can be abbreviated to:
ip a
If you still prefer to use ifconfig
as part of your daily sys admin routine, you can easily install it as part of the net-tools
package.
apt-get install net-tools
Reference is here
How to browse localhost on Android device?
I use my local ip for that i.e. 192.168.0.1 and it works.
how to access localhost on android device
USB doesn't provide network to mobile device. If it's connected to your wifi, then hit your laptop address provided by the router. If it's connected to your mobile network, then first find out your router external IP address, then forward some port to that 10.0.2.2:portno and finally you'll be able to see that server from your device.
How can I access my localhost from my Android device?
USB doesn't provide network to mobile device.
If both your desktop and phone are connected to the same WiFi (or any other local network), then use your desktop IP address assigned by the router (not localhost
and not 127.0.0.1
).
To find out the IP address of your desktop:
- type into the command line
ipconfig
(Windows) orifconfig
(Unix)- on Linux the one-liner
ifconfig | grep "inet " | grep -v 127.0.0.1
will yield only the important stuff - there's a bunch of suggestions on how to have a similar output on Windows
- on Linux the one-liner
- there's going to be a bunch of IP's
- try all of them (except the forementioned
localhost
and127.0.0.1
)
If your phone is connected to the mobile network, then things are going to be harder.
Either go hardcore:
- first find out your router external IP address (https://www.google.de/search?q=myip)
- then, on the router, forward some port to
<your desktop IP>:<server port number>
- finally use the external IP address and forwarded port
Otherwise use something like xip.io or ngrok.
NOTE: The ifconfig
command has been deprecated and thus missing by default on Debian Linux, starting from Debian stretch. The new and recommended alternative for examining a network configuration on Debian Linux is ip command. For example to use ip command to display a network configuration run the following:
ip address
The above ip command can be abbreviated to:
ip a
If you still prefer to use ifconfig
as part of your daily sys admin routine, you can easily install it as part of the net-tools
package.
apt-get install net-tools
Reference is here
Viewing localhost website from mobile device
To view localhost website from mobile device you have to follow thoses steps :
- In your computer, you have to retrieve your IP address (Run > cmd > ipconfig)
- If your localhost use a specific port (like localhost:12345 ), you have to open the port on your computer (Control Panel > System and Security > Firewall > Advanced settings and add Inbound rule)
- Finally, you can access to your website from mobile device by navigate to : http://192.168.X.X:12345/
Hope it helps
Access localhost from Android device
Check public ip of your pc by ifconfig
command in terminal
then use YOUR_IP/myphpServer
If you are in local network (router or LAN) then use your local_ip/myphpServer
(make sure your mobile is also in same network)
If your mobile doesn't have internet connection then go for Android USB Tethering
Related Topics
How to Call Wi-Fi Settings Screen from My Application Using Android
How to Add Items to a Spinner in Android
Encryption Error on Android 4.2
How to Check If Url Is Valid in Android
Movecamera with Cameraupdatefactory.Newlatlngbounds Crashes
Programmatically Getting the Gateway and Subnet Mask Details
Programmatically Relaunch/Recreate an Activity
How to Open/Display Documents(.Pdf, .Doc) Without External App
Scrollview Can Host Only One Direct Child
Android Studio, Suddenly Got Gpu Driver Issue When Running Emulator
How to Block a Mobile Number Call and Message Receiving in Android Application Development
How to Set Textinputlayout Error Message Colour
Why Use Android Picasso Library to Download Images
Use "Enter" Key on Softkeyboard Instead of Clicking Button