This article is about how to access Localhost on your mobile browsers and view the website running on your Localhost from your mobile in real-time.
So, if you are working on a website or a web application and want to view the pages on your mobile, this article will help you do that easily.
Table of Contents
Generally when we develop a website and want to check its responsiveness, we usually open our Chrome inspect tools and check the mobile view in our desktop browser itself.
However, sometimes we need to check the touch event or other events which is only possible on a real mobile device. So for that accessing Localhost from our mobile device becomes important.
Access Localhost on your mobile browsers.
To access your localhost from your mobile follow the steps below:
Step 1: Connect your Phone to the same Network
First, make sure that your computer and your mobile device are connected to the same Wifi Network. This is very important.
Step 2: Start your Development Server
Start your application on your local machine first. Once it opens in your browser, you will get the URL as localhost:3000
, now write down the post number which is 3000
in this case.
Step 3: Find your computer’s local IP Address
Open the command prompt, type this command, ipconfig
and press Enter. You will get lots of information on the screen but we only need the IPv4 address
. The IPv4 address looks like 192.164.45.1.
IPv4 address will different in your PC.
If you are thinking about “How to find my local IP address in Linux and Mac”, see the instructions below.
In Linux, run this in your terminal: hostname -I
or ifconfig
command.
In Mac, Open System Preferences > Network. Then in the Wi-Fi tab, under the status, you will see your IP address.
Step 4: Open Mobile device Browser
Once you have the Port Number and the IPv4 address.
Open your mobile or tablet browser and type IPv4 Address: PORT. For example 192.164.45.1:3000
That’s it, now you can test your web application on your mobile device in real-time.