6

I have a wamp server in localhost. I tried to make http request from my android app. But cannot get it right. Many said 10.0.2.2:8080 will point to localhost from emulator. So i tried to open it in web browser from emulator. i typed in url as "10.0.2.2/cifi/test.php". But emulator popped error as "net:CONNECTION_TIMED_OUT"

Need explanation: how to make my wamp server in local machine to listen 10.0.0.2:8080 from emulator's browser.

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
IhtkaS
  • 1,314
  • 3
  • 15
  • 31
  • There is something you are not tell us. Is your emulator running in a Virtual Machine?? – RiggsFolly Feb 04 '14 at 21:20
  • 1
    For Genymotion, 10.0.3.2 - from: http://stackoverflow.com/a/20914067/2162226 – Gene Bo Mar 08 '15 at 22:45
  • Moved from answers to comments: It finally worked! I used "10.0.2.2:80/cifi/test.php". My wamp server listens only to that port. Thanks to everyone who wanted to help me! – IhtkaS Jul 16 '20 at 09:00

3 Answers3

3

Weirdly enough, in my case, I had to turn on and off the airplane mode to get it working.

Orkhan Alikhanov
  • 9,122
  • 3
  • 39
  • 60
2

Your Wamp Server seems to be accepting only localhost connections.

Left click on wamp icon -> put online

Additionnally you should type a url http://10.0.2.2:8080/cifi/test.php instead of http://1.0.2.2/cifi/test.php

TheCopycat
  • 401
  • 2
  • 6
  • yeah i use easyphp wamp server. i started it...i can open it from my windows browser. But its not working in emulator's browser.And i nowhere mentioned i used "http://1.0.2.2/cifi/test.php" – IhtkaS Feb 02 '14 at 12:17
  • You just wrote in your question : "i typed in url as "10.0.2.2/cifi/test.php". But emulator popped error as "net:CONNECTION_TIMED_OUT"" – TheCopycat Feb 02 '14 at 12:18
  • Have you tried the other thing I mentioned in my answer ? left click on wamp icon -> click `Put online` – TheCopycat Feb 02 '14 at 12:32
  • @TheCopycat What is put online? It doesn't work again. – Dr.jacky Jul 02 '14 at 11:06
0

Just got the same problem and resolved it by executing:

adb reverse tcp:8080 tcp:8080

That said, after I revoked forwarding, the host machine remained visible and all ports were working, so it is unclear how it works.

Make sure that

  • You don't have a proxy set in WIFI settings
  • If you do, then 10.0.2.2 is added to bypass without a mask
  • That you didn't make a typo, like you already did in the post with 10.0.0.2:8080
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
Roger
  • 11
  • 2