Error Codes Wiki

Browser Geolocation Errors — Permission Denied and Position Unavailable

Warningpermissions

Overview

Fix browser Geolocation API errors including permission denied, position unavailable, timeout, and accuracy issues on desktop and mobile browsers.

Key Details

  • Geolocation API provides GPS coordinates via navigator.geolocation.getCurrentPosition()
  • Error codes: 1 (PERMISSION_DENIED), 2 (POSITION_UNAVAILABLE), 3 (TIMEOUT)
  • Geolocation requires HTTPS — insecure origins are blocked from accessing location
  • Desktop browsers use WiFi-based location (less accurate) unless a GPS module is available
  • Mobile browsers use GPS, WiFi, and cell tower triangulation for location

Common Causes

  • User denied the location permission prompt
  • Site not served over HTTPS — geolocation is blocked on insecure origins
  • No location sources available (no WiFi, no GPS) causing POSITION_UNAVAILABLE
  • Timeout value too short for the device to acquire a GPS fix
  • OS-level location services disabled (macOS Privacy, Windows Location, Android GPS)

Steps

  1. 1Check HTTPS: geolocation only works on secure origins (https:// or localhost)
  2. 2Enable OS-level location: Windows Settings > Privacy > Location, macOS System Settings > Privacy > Location Services
  3. 3Reset browser permission: click the lock icon in the URL bar > Site settings > Location > Allow
  4. 4Increase timeout: getCurrentPosition(success, error, {timeout: 30000}) for slow GPS acquisition
  5. 5Use enableHighAccuracy: true for GPS-level accuracy (slower but more precise on mobile)
  6. 6Handle errors gracefully: implement fallback to IP-based geolocation when permission is denied

Tags

geolocationgpspermissionlocationcoordinates

Related Items

More in Permissions

Frequently Asked Questions

On mobile with GPS: 3-10 meters. On desktop via WiFi: 20-100 meters. Without WiFi: IP-based geolocation is only accurate to the city level (1-50km).