user2868276
user2868276

Reputation: 289

How can I access my localhost through Android phone?

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?

Upvotes: 28

Views: 112092

Answers (6)

Mike
Mike

Reputation: 39

So, I was recently trying to do the same... I am using a framework like Opencart. Which allowed me yo use "localhost" as host name to run my initial setup. If you did the same. Go back to your config.php for your app and change the HTTP_SERVER from localhost to your ip address(found from techniques above). You must do it in your DB_HOSTNAME also. And you will need to either edit or create a new DB user that uses the ip address as the HOSTNAME. You create and modify DB Users in the phpMyAdmin of XAMPP.

Then instead of http://localhost/yourapp_path/ it will be: http://your.local.ip.address/yourapp_path/

Upvotes: 0

Mehul
Mehul

Reputation: 2149

It is very simple, just follow this steps:

  1. Get your PC's IP address by typing IPCONFIG command in command prompt.
  2. Copy your IP address from the list which is under the wifi configuration area.
  3. In your android app code specify your IP Address.
  4. very important step put your server on-line .

Upvotes: 3

Ameen Maheen
Ameen Maheen

Reputation: 2747

If you are using ubuntu please go through this to find your local IP Address on the network and append it to the url instead of local host . worked for me

Eg :http://192.168.1.10/qrstuff/json/

Upvotes: 1

Seyyed
Seyyed

Reputation: 1534

  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!

Upvotes: 20

Saad Bhutto
Saad Bhutto

Reputation: 397

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

Upvotes: 37

Ahmed Ekri
Ahmed Ekri

Reputation: 4651

USB doesn't provide network to mobile device. If it's connected to your wifi, then hit your laptop address provided by the router. If it's connected to your mobile network, then first find out your router external IP address, then forward some port to that 10.0.2.2:portno and finally you'll be able to see that server from your device.

source: https://stackoverflow.com/a/4779992/1932105

or this:

It is very simple

Turn on Wifi Hotspot of your android phone and connect your Laptop with your phone.

Start your server at localhost (I am using wamp server)

Now open command prompt and enter ipconfig command you will get following things

Wireless LAN adapter Wireless Network Connection:
  Connection-specific DNS Suffix  . :
  Link-local IPv6 Address . . . . . : fe80::80bc:e378:19ab:e448%11
  IPv4 Address. . . . . . . . . . . : 192.168.43.76
  Subnet Mask . . . . . . . . . . . : 255.255.255.0
  Default Gateway . . . . . . . . . : 192.168.43.1

Copy this 192.168.43.76 in your mobile browser.

Note : Please set you network as "Home Network".

source: https://stackoverflow.com/a/15864222/1932105

please use the search next time.

Upvotes: 7

Related Questions