Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I access my localhost through Android phone?

Tags:

I want to connect my Android phone to XAMPP server of my pc to run my app on phone's browser (app is working fine with pc's browser).

I am using broadband connection. The only solution which I've got until date is through using wifi connection.

But, I am restricted to use LAN connection. How can I connect it without using a router?

like image 380
user2868276 Avatar asked Oct 12 '13 08:10

user2868276


People also ask

How can I access my localhost from mobile?

You can access your host machine with the IP address "10.0. 2.2". This has been designed in this way by the Android team. So your webserver can perfectly run at localhost and from your Android app you can access it via "http://10.0.2.2:8080".

How do I connect to my localhost?

To access the server from itself, use http://localhost/ or http://127.0.0.1/ . To access the server from a separate computer on the same network, use http://192.168.X.X where X.X is your server's local IP address. You can find the sever's local IP address (assuming it's Linux) by running hostname -I . 127.0.


2 Answers

its very simple , - GOTO command line (Window + R [type cmd]) - type ipconfig , that will show the current IP address of your PC - write taht IP address on your Android Phone's browser with :80 e.g (http://192.168.x.x:80)

Done

localhost will appear on your Phone

like image 123
Saad Bhutto Avatar answered Dec 18 '22 07:12

Saad Bhutto


  1. Retrieve your IP address:
    In Ubuntu: type ifconfig in terminal
    In Windows: type ipconfig in cmd`
  2. Disable your Firewall
    In Ubuntu: type sudo ufw disable in terminal
    In Windows: Go to "Control Panel> System and Security> Windows Firewall" and turn it off.
  3. Insert retrieved IP address into your phone browser.
    (Your XAMPP local server must be running)
    Well done!
like image 29
Seyyed Avatar answered Dec 18 '22 09:12

Seyyed