$http request works on browser and IOS but fails on Android


Hello guys,
I have a simple app that make some requests to a back-end api.
It works like a charm on the browser and IOS simulator, but it fails on Android.

The request does not touch my server. The error occurs inside the createHttpBackend function on $http lib. The error line is selected bellow:

I think it is a particular config that I am missing for the Android platform because it works in browser/IOS.

The request code is simple:

$http.get(“http://localhost:3000/api/v1/stores.json”).success(function(d) { console.log(“d”);}).error(function(e) { console.log(“errr”);})

Thanks for your attention,
kind regards Bruno.


Hi @bfb,

Can you run adb logcat for Android and paste results?

That should put us in the right direction.


Hi @nicraboy thanks for your answer.
Here is the log produced by the “adb logcat” command in the request moment.



Perhaps like me you just learned the hard way that Android emulators run on their own IP, not localhost. So if you are trying to connect to http on “localhost” it will fail. I changed it to our public stage server and it worked like a champ.


i am not sure but i remember i got a problem exactly with that line. What worked if i can remember was to delete the plugins and the platforms directory, then add the android platform again and plugins.


Thanks @TrikinCurt this was the problem, the Android emulator has his own ip.

Thanks @duall for your attention.

regards Bruno


Aside from localhost needing to be an actual IP, you’ll have to add cordova-plugin-whitelist in the newer versions of things to make the HTTP request work on android