10.0.2.2:8080 in web browser in emulator is not working
Asked Answered
B

3

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.

Boniface answered 2/2, 2014 at 11:59 Comment(3)
There is something you are not tell us. Is your emulator running in a Virtual Machine??Brookins
For Genymotion, 10.0.3.2 - from: https://mcmap.net/q/1775360/-udp-from-androidemulator-genymotion-to-localhost-server-10-0-2-2-does-not-workStudley
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!Boniface
R
6

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

Rento answered 19/1, 2018 at 14:19 Comment(1)
Still worked for me in 2023 on Android 13Throughput
L
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

Lues answered 2/2, 2014 at 12:6 Comment(4)
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 "1.0.2.2/cifi/test.php"Boniface
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""Lues
Have you tried the other thing I mentioned in my answer ? left click on wamp icon -> click Put onlineLues
@Lues What is put online? It doesn't work again.Extender
A
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
Adnah answered 26/6, 2021 at 10:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.