Articles » How to access localhost on a mobile device.
How to access localhost on a mobile device.
1 February, 2022
In this guide we will follow the steps below that will allow us to view our website running on our localhost server on a mobile device, or any device that is not physically connected to our localhost machine as long as we are on the same network.
- Start up your website/app on your localhost server.
- Get your localhost IP address.
- Configure the firewall to open any required ports.
- Test localhost access on your mobile device.
Start up your website on your localhost server
In my case, I am running a local VueJS app on localhost which shows me that my app/website is running and accessible on http://localhost:8081/ or http://192.168.0.17:8081/
In your case, this could be a php website, a React JS app, etc. The main thing is to ensure that your website or app is accessible through http://localhost.
Get your localhost IP address
Now we need to find the IP address of our localhost. As shown above, this is already provided to us by the Vue JS CLI which is 192.168.0.17.
However, if this is not the case for you, a quick way to obtain the localhost IP address is the following.
- Open the Command Prompt.
- Type in “ipconfig” and press Enter.
- Look for the Wireless LAN adapter Wi-Fi which will show you the IPv4 Address.
Configure the firewall to open any required ports - Windows 10
Next, we have to open the required firewall ports to access our website or app on a mobile device.
- Go to “Control Panel” -> “Windows Defender Firewall”.
- Click “Advanced Settings”.
- Select “Inbound Rules”.
- Click “New Rule…” on the right side of the window.
- Select “Port” and click “Next”.
- Select “TCP or UDP” and choose “Specific local ports”. Usually TCP is fine for the ports we want to open to access our localhost such as port 8080.
- Enter the ports you want to open and click “Next”. In my case, my app is served on http://192.168.0.17:8081 so I will enter 8081.
- Select “Allow the connection” and click “Next”.
- Check the connection settings you see fit such as Domain, Private, or Public and click “Next”.
- Give a name and description to the new rule and click “Finish”.
Test localhost access on your mobile device
On your mobile device, open your browser and navigate to your localhost IP address and include the port as well if required.
You should now be able to see your website or app on your mobile device.
Post your comment
Comments
No one has commented on this page yet.
RSS feed for comments on this page | RSS feed for all comments