Sid
Sid

Reputation: 455

Accessing localhost in android application

I am making an application that needs to access the server database. But since its still in the early stage, I have to delete the database quite often which is a problem because its used for other web applications too.

So I was thinking if I could test my application against my localhost database it would make it much easier for me. I tried a few solutions on stack overflow but they didn't work for me so here is my problem.

I have lamp setup on my system. In my browser, I can access localhost using 127.0.0.1 but if I try the same thing on my phone's browser it shows that the connection was refused. Both my laptop and phone are connected to the same wifi network. Is there some permission I have to provide that I am not aware of?

Upvotes: 2

Views: 83

Answers (2)

Dbdj82
Dbdj82

Reputation: 58

You should try to access to your laptop by using its IP address. If your laptop is running on Windows, run the command ipconfig from a Command Prompt Window and then use the ip address the command returned on your phone's browser.

This should work.

Upvotes: 0

William Ku
William Ku

Reputation: 798

your 127.0.0.1 refers to your desktop.

Find out the local ip of your desktop (example 192.168.0.2) and then use that ip on your mobile browser

Upvotes: 1

Related Questions