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 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
How can I access my localhost from my physical Android device?
Try this:
php artisan serve --host 0.0.0.0 --port 80
Just make sure that the port is free.
Reference: https://stackoverflow.com/a/30675683/5192105
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
Handle Textview Link Click in My Android App
How to Use the New Sd Card Access API Presented For Android 5.0 (Lollipop)
Android Studio Installation on Windows 7 Fails, No Jdk Found
Android Studio Suddenly Cannot Resolve Symbols
How to Send Image Via Mms in Android
Android - Implementing Startforeground For a Service
How to Display a Toast from a Background Thread on Android
Android Studio Adds Unwanted Permission After Running Application on Real Device
How to Get the Device'S Imei/Esn Programmatically in Android
Integrating the Zxing Library Directly into My Android Application
How to Update Gradle in Android Studio
Android: How to Prevent the Soft Keyboard from Pushing My View Up
How to Put Google Maps V2 on a Fragment Using Viewpager
Recyclerview Inside Scrollview Is Not Working
How to Completely Uninstall Android Studio from Windows(V10)