Ionic geolocation Only secure origins are allowed error

I m building Android app in Ionic2 and Cordova i m using native Geolocation and google maps. Geo location in browser works well but when i run it on android I’m get flowing error: Only secure origins are allowed (see:
Here is code:

Geolocation.getCurrentPosition(options).then((position) => {

      let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);

      let mapOptions = {
        center: latLng,
        zoom: 15,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      } = new google.maps.Map(this.mapElement.nativeElement, mapOptions);

    },function(err){console.log("ERROR: " + err.message)});

Hmm, nothing looks out of place.

Could you put together a simple demo of push it to github. I’d like to test it out.


It’s a new secure procedure from google, Geolocation is only allowed from HTTPS and no longer supports HTTP. But i just couldn’t find a way to make it work. Can you help ?


me too,
thought it was a Chrome Browser only problem, but i got this now on android emulator

ionic emulate android --dev -lc

Indeed this is happening on my device now :frowning:
Working fine in the browser, seems to be a cordova issue with Geolocation.getCurrentPosition() etc

1 Like

An update on this is that for a signed production Android release the problem does not exist, so it’s only affecting the development build.
Also it’s only a problem when using live reload, if just doing “ionic run android” there is no error.
Google regard “localhost” as secure, but others as not.
I think it’s something to do with the fact that when the android build is connecting back to the dev machine, it has to do so on an IP address, so something other than localhost.
I think it’s this that is causing the problem.


Have the same issue with Android emulator, however works fine in browser and iOS emulator.

How to test on Android emulator?

so what to do if we need the livereload in order to develop the app?

Is there a way to fix the Only secure origins are allowed error? I am testing my App on Android using ionic run android -l -c -s

it was working just fine a month ago! I tried it today and it just won’t work and it returns the above error.

  • I am using Ionic not Ionic2

Same problem here, in the browser it works, but as soon as u try the app in the android emulator u get that error. Any help?

I have come to the same conclusion.
The only workaround I see is to launch “Live Reload” under https but I don’t know if it’s possible ?

Any news here? I get the same error now.

Thank @danielabbatt it work for me.

I have same problem, did you find a solution with livereload ?

I let my message here :

Thank you

1 Like

Just run google chrome without web security. in linux

google-chrome.exe --disable-web-security

Will do. For windows search Internet.

1 Like

I have the same problem

Where are you run the App on browser or some device?

I run the App on Android device with --livereload

@fdambrosio… You need run the app witthout --livereload, this is the problem, because when you use that flat, your app is not using the native components. I had the same issue.

1 Like

Thanks, yes I know, but I’m trying to find some way to do that…