iOS simulator $http not working



I am struggling to get $http to work inside a normal standalone Dummy application inside an iOS simulator.

What I did was:

  • $ ionic start Dummy
  • $ ionic plugin add
  • $ ionic platform add ios

The I amended only the DashCtrl to the following:

.controller('DashCtrl', function ($scope, $http, $ionicPlatform) {
    $ionicPlatform.ready(function() {
            .success(function(data, status) {
            .error(function(data, status) {

The when I try $ ionic run ios -l -c -s I see that the .error() is being called not .success()

The navigator.connection.type logs wifi

However when I look at the logs on for apache I see that the file.txt was returned, status 200 with the correct amount of bytes. Not sure why the $http.success is not firing?

Some details from my setup:

$ ionic info

OS: Mac OS X Yosemite
Node Version: v0.12.0
Cordova CLI: 4.2.0
Ionic Version: 1.0.0-rc.0
Ionic CLI Version: 1.3.13
Xcode version: Xcode 6.1.1 Build version 6A2008a 
ios-sim version: 3.1.1

$ ionic plugin list

com.ionic.keyboard 1.0.4 "Keyboard"
org.apache.cordova.console 0.2.13 "Console"
org.apache.cordova.device 0.3.0 "Device" 0.2.15 "Network Information"

Thanks for the help


plz try to change the listening port, more detail here:


@sarale Are you thinking it is a cors problem? The is just for testing purposes and is a local apache server on the same IP that the ionic run would bind to. If I build an android apk and install it to the device it does work. So seems to be a simulator thing?

  $http({method: 'GET', url: })

Try this way, I had similar problems simulating iOS, occupy this syntax and run.


Thanks, changed to

$http({method: 'GET', url: ''})
            .success(function(data, status) {

produced the same issue. Still calling .error()


did u try the path inside your navigator, what is the result ?


Why not install gapDebug? It’s free and you can verify that really happens in the simulator with plugins and errors, you maybe out there specifically error occurring.


@sarale Yes I did try from a browser and even from Safari browser inside the emulator and the test little file does come back.

Running $ ionic run ios -l -c -s brings back the following:

Running dev server:
Running live reload server:

So the apache test server is running on the same machine as the simulator. But even if I change the http:// to anything else I still just get the .error() function being called.

@sioesi I must be honest, I am new to the cordova world, do not even know about gapDebug. Will have a look and see if I can get it installed.

Thanks for the help. Not sure what is happening here. Its such a basic thing, just trying to get $http to return a valid file form the simulator.


I must just add (to be clear), if I build an android app the $http works fine. I am just having the issue inside the ios emulator and android emulator.


Gabdegub is, you could have a look, I occupy for a similar mistake and helped me a lot, available for both platforms free tool I leave the link, brings a good tutorial to configure the devices and emulators here.


anything, that mistake will deliver the log?


@sioesi Thanks for the GapDebug info. I downloaded GapDebug, ran my app with just $ ionic run ios, gapDebug then brought up the Simulator, I loaded the app from the simulator and it registered with gapDebug. In the console of gapDebug the $http worked without an issue. So it must be something with trying $ ionic run ios -l -c -s in a live environment. At least now I have a nice debug environment.


Good thing you have served, however try to test your app in a real device, I had many problems with the simulator once in a physical device all problems were solved and also GapDebug helped me a lot :slight_smile: Good luck!


This error is due by CORS problem of your destination server which does not support “localhost” headers.
Infact if you execute your code from a Device or from the simulator without node server (so without -l -c -s) it gonna work perfectly.