Tuesday, 1 September 2015

How to access localhost of my local machine from android

In this post I will explain how to access localhost of your laptop using android.

Those who have worked on making local server and access it from the local machine's browser may know that we can just access the localserver by its ip and port no. on which server is running.

Like Type in browser

http://yourserverip:portno

For example : http://192.168.1.104:80

You can also access the localhost server from phone's browser by typing the same ip and port.

But in Mac OS it does not work sometimes. It gives the error host unreachable.

That is because your router is not able to find the route to the given ip. For this you have to first ping the server ip from your terminal.(if you are using other machine is not android).

open Terminal Type  : ping ipaddreessofserver

Note: Replace ipadressofserver  by your server's ip address.

But If you are in android you might not have a terminal. So Go to play store Download an app called

ConnectBot. 


It basically provides you a terminal to access in android. Type ping ipaddressofyourserver in connectbot app in your android phone. If ping is working then you will be able to access localhost from browser of your android phone.

I hope this is helpful. If you have any other doubts regarding this please comment. If you like the post share it.


2 comments:

  1. Well, emulator calls localhost by your PC's ip, look like these ip's, 192.168.0.104 or 172.16.0.23.
    These can easily be found in windows by using ipconfig command or in linux based OS'es by using ifconfig command in terminal.

    OR

    You can simply use 10.0.2.2/80 to use your localhost on emulator or to connect to your XAMPP server :)

    ReplyDelete
    Replies
    1. First of all I am glad that you spend some time on reading this post. And yes you are correct but when you will try to connect from android to mac pc's localhost , You will face some error:Host unreachable as I explain in this post. That post was not for general connection to localhost. It was for that error which you will get while using mac.

      Thanks

      Delete

Related Posts

Related Posts Plugin for WordPress, Blogger...