getCurrentPosition problem with some devices

Hi!

A new Retool user here trying to figure out how to get user's location in my app. I have this Query "GetUserLocation":
{
const pos = await utils.getCurrentPosition();

return {
lat: pos.coords.latitude,
lng: pos.coords.longitude

}
};

It works just fine with two different laptops and with my cellphone. But not with another user's cell or tablet. It doesn't matter if the browser is Safari or Chrome. The problem is, that the browser doesnt' even ask for permission for geolocation. And if I manually allow location in browser's settings, location comes back as "undefined". Any ideas how to solve this?

Hello @Mikko_Pirttila, welcome to the Retool Community :wave:,

You're on the right track using utils.getCurrentPosition(), but this behavior usually points to browser-level permissions or HTTPS issues. Here's what to check:


1. Make sure the app is being served over HTTPS

Geolocation APIs require a secure context (HTTPS or localhost). If your Retool app is being accessed over HTTP, the browser will silently block location requests without prompting.

Try accessing the app via https://yourapp.retool.com, not http://.


2. Clear site settings and reset location permissions

Sometimes browsers remember a previous β€œBlock” choice and won’t ask again. On the affected device:

  • Go to browser settings > Site settings > Location
  • Remove/revoke saved settings for your Retool app
  • Reload the page β€” you should get the permission prompt again

3. Check browser and OS settings

On some mobile browsers (especially Safari on iOS), geolocation permissions are tied to:

  • App-level location settings (check if location is allowed for Safari or Chrome in iOS Settings)
  • Screen time / parental controls (can restrict access silently)

Also make sure:

  • Browser has permissions enabled for location
  • "Precise location" is turned ON (especially on iOS 15+)

4. Add fallback error handling in your code

It helps to catch errors and log them for debugging:

try {
  const pos = await utils.getCurrentPosition();
  return {
    lat: pos.coords.latitude,
    lng: pos.coords.longitude
  };
} catch (err) {
  return { error: err.message || 'Location access failed' };
}

This can help you confirm if the issue is a permission denial or something else.

5 Likes

Thanks, but I believe I have ruled out device/browser related issues. I even tried to manually allow location for Retool although it was never asked by the browser but it did not make any difference. The same with Safari and Chrome.

Hi @Mikko_Pirttila, I am unable to reproduce your issue. My utils.getCurrentPosition works on all my devices and my coworker's device to boot! Can you send me the exported json file from your app and I will take a look at it?

4 Likes