Many times you are working in your project in your local computer and you want to check how your website will look in mobile phone. It is also become necessary to having mobile friendly website for SEO. So, in this tutorial, I will tell you how to open localhost website from your mobile phone.

If your localhost computer and phone are connected to the same WiFi, then use your desktop IP address assigned by the router.

You can find the IP address of your desktop by running following commnad in Terminal 

ifconfig

And you will get bellow response. find section like wlp2s0 and check IP address of the computer.

Or use this command to get exact details:

ifconfig | grep "inet " | grep -v 127.0.0.1

If your localhost computer is Windows system, then open CMD and run bellow command:

ipconfig

Now open browser in your moblie and run IP address with port. It will open your localhost website in mobile.

In windows system, if you have used XAMPP and you have get 403 error then, in XAMPP Control Panel, next to Apache line, click on the Config button and open httpd-xampp.conf. There is line Require all local in the bottom of the file, change it to Require all granted and re-run the Apache server.
For example if you have run your project in 8000 port and your computer IP address is 192.168.1.102, then run 192.168.1.102:8000 in your mobile browser.

If your phone is not connected to the same network, then you can use third party client like ngrok or xip.io. I will try ngrok. For that go to ngrok and download ngrok client installer file according to your operating system. Unzip file and go to the folder path in Terminal or CMD.

Now run the following command with localhost port, i.e. 8000.

./ngrok http 8000

It will foward your localhost to specific website. Open this website from anywhere, you can access it in mobile or in your computer system.

This way, you can open localhost website in your mobile. I hope you liked this article.


Was this article helpful?

0 out of 0 person found this article helpful.

Leave a comment

OR

No Comments