Access your localhost on iPhone or Android | 100% working | 2021

 



Very often we make web apps that we wish we could test on our phone. Sometimes you might be hosting something and you wish you could access it outside your computer. Well, the solution to this is very easy. More easy than what you would think.

For things to make sense let me give you a quick insight first.

How do devices get connected over network in the first place?

To connect to the Internet/Local network and other computers on a network, a computer must have a NIC (network interface card) installed. 
A network cable plugged into the NIC on one end and plugged into a cable modem / DSL modem / router / switch can allow a computer to access the Internet and connect to other computers.

Like in the picture above, all devices need to connected to each other in the first place in order for the files to be transferred/shared between them.

What happens next?

Once you have devices connected over the same network. It can be anything, like your home Wi-Fi.
Now, pay concentration here:

The whole networking of devices is based on something we call, IP address and Ports.
An Internet Protocol address (IP address) is the logical address of our network hardware by which other devices identify it in a network. While Port number is the part of the addressing information used to identify the senders and receivers of messages in computer networks. Different port numbers are used to determine what protocol incoming traffic should be directed to.

We are almost there.

Now all your need to do is:
1. A localhost running on your laptop/pc/mac.
2. Go to your wifi/ethernet settings and find your ip there. Let's say it's 192.168.1.10
3. If you are using any serving application/plugin or any other software, make sure you know the port. Usually its 80 or 8080 but it can be aything.
4. Now on your phone / other device. Open your browser and in url type http://192.168.1.10:8080

That's it. It's peanuts!

What else can be done with this?

The possibilities are endless. You can do anything with it. I personally use Linux and my Rythmbox is always running, so I am using a plugin that allows me to use media controls through web. Also I use this to test my websites on phone that I develop on my laptop. It's so easy and fun.
I personally feel that you can create a whole network on things in your home. There are plenty of open-source softwares available that you can give a try.

If you still find it hard, let me know in comments.

Post a Comment

Post a Comment (0)

Previous Post Next Post