1

I have an issue when I trying to call my web service by pointing to the machine in LAN.

After some search over SO I have found that I cant use following patterns

  1. http://localhost/..
  2. http://localhost:port/..
  3. http://127.0.0.1:port/..

Then I tried to access it by specifying my machine name like this.

  1. http://machine_name:port/....
  2. http://machine_name/....

Still it is not working from my android device. Can any one explain why I can do this? And Ho can I achieve this?

Can anyone make this idea clear? because I want to know the differences in accessing a local server machine from other machines in same LAN and from an android phone. :)

Dennis MP
  • 12,084
  • 10
  • 43
  • 61

3 Answers3

1

if you testing in emulator than you have to use

10.0.2.2

if you are using phone connected in same LAN then you have to use ip address of you server machine.

Imtiyaz Khalani
  • 1,943
  • 16
  • 31
0

Goto Command prompt, type ipconfig Then note down your ipv4 address. you will find something like 192.168.xxx.xxx put that address as url

Akshay Shinde
  • 927
  • 10
  • 23
0

Localhost and 127.0.0.1 point to the current machine you are requesting from. So when connecting to localhost or 127.0.0.1 on your Android, the request is sent to your android and never leaves as it is asking for a connection to itself (which it is most likely not setup for)

Therefore, to connect to your dev machine from a remote device, the simplest of ways is to find the IP address of your dev machine and attempt to use that as the address on your Android or any other remote device on your local network.

Sators
  • 1,655
  • 15
  • 20