Error Codes Wiki

Browser Geolocation Errors — Permission Denied and Position Unavailable

Warningpermissions

About Browser Geolocation Errors

Fix browser Geolocation API errors including permission denied, position unavailable, timeout, and accuracy issues on desktop and mobile browsers. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.

Here are the key things to understand: 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. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.

The most common reasons this occurs include: 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). Identifying the root cause is the first step toward finding the right solution.

To resolve this, follow these recommended steps: Check HTTPS: geolocation only works on secure origins (https:// or localhost). Enable OS-level location: Windows Settings > Privacy > Location, macOS System Settings > Privacy > Location Services. Reset browser permission: click the lock icon in the URL bar > Site settings > Location > Allow. Increase timeout: getCurrentPosition(success, error, {timeout: 30000}) for slow GPS acquisition. Use enableHighAccuracy: true for GPS-level accuracy (slower but more precise on mobile). Handle errors gracefully: implement fallback to IP-based geolocation when permission is denied. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.

This article is part of our Browser Errors collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.

Quick Answer

How accurate is browser geolocation?

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).

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).