2

How to Access Localhost on Mobile Browsers

 1 year ago
source link: https://www.laravelcode.com/post/how-to-access-localhost-on-mobile-browsers
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How to Access Localhost on Mobile Browsers

  2268 views

  6 months ago

Laravel

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.

open-localhost-website-in-mobile-find-ip-address-computer.png

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
open-localhost-website-in-mobile-ngrok.png

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.

Author : Harsukh Makwana
Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK