Geolocation Test
Check the browser Geolocation API on this device: permission state, accuracy, watchPosition updates, and what a website can tell from your IP address alone.
1. What this browser supports
- Secure context (HTTPS)…
- navigator.geolocation…
- Permission statechecking
The permission state comes from navigator.permissions.query({ name: "geolocation" }) and updates live if you change it in site settings. Safari added this query in version 16.
2. Run the test
Options: timeout 20000 ms, maximumAge 0. Nothing is requested until you press a button, and the coordinates never leave your browser.
Browser position (GeolocationCoordinates)
| latitude | … |
|---|---|
| longitude | … |
| accuracy | … |
| altitude | … |
| altitudeAccuracy | … |
| heading | … |
| speed | … |
| timestamp | … |
| time to first fix | … |
| watch updates / best accuracy | 0 / … |
IP-based location (no permission needed)
| ip | … |
|---|---|
| place | … |
| latitude | … |
| longitude | … |
| isp | … |
| proxy / VPN | … |
| IP vs GPS distance | run the test |
A distance in the hundreds of kilometres usually means a VPN, a mobile carrier gateway, or an IP block registered at the provider's head office. Why IP location shows the wrong city.
3. Raw GeolocationPosition
// press getCurrentPosition() or watchPosition()
4. Our IP API response
// loading GET /api/ip
This is exactly what GET https://whatismylocation.org/api/ip returned for your connection. It is the location any website can infer without asking you.
How to get the current location of the user in JavaScript
Browsers expose the device position through navigator.geolocation. It only works on HTTPS (or localhost), and the browser asks the user first. The page above calls exactly this code:
// One reading
navigator.geolocation.getCurrentPosition(
(pos) => {
const { latitude, longitude, accuracy } = pos.coords;
console.log(latitude, longitude, "±" + Math.round(accuracy) + " m");
},
(err) => console.warn(err.code, err.message), // 1 denied, 2 unavailable, 3 timeout
{ enableHighAccuracy: true, timeout: 20000, maximumAge: 0 }
);
// Continuous updates (call clearWatch(id) to stop)
const id = navigator.geolocation.watchPosition(onPosition, onError, options);
// Check the permission without triggering the prompt
const status = await navigator.permissions.query({ name: "geolocation" });
console.log(status.state); // "granted" | "prompt" | "denied"Error codes
| code | name | usual cause |
|---|---|---|
| 1 | PERMISSION_DENIED | The user or a policy blocked access, the page is not HTTPS, or the OS has location services off for the browser. |
| 2 | POSITION_UNAVAILABLE | No GPS, Wi-Fi or cell data could produce a position, or the network location service could not be reached. |
| 3 | TIMEOUT | No fix arrived within timeout. Common indoors with enableHighAccuracy: true on phones. |
How accurate should the result be?
- Phone outdoors with GPS: usually 3 to 20 m, after a few seconds.
- Laptop on Wi-Fi: usually 15 to 100 m, from nearby access points.
- Desktop on a cable connection: often 1 to 50 km, because only the IP address is available.
- IP address only: right country almost always, right city most of the time, and wrong by hundreds of km behind a VPN or some mobile carriers.
accuracy is a radius in metres at 95% confidence. altitude, heading and speed are null on most laptops because they have no GPS receiver.
Related tools
- What is my location: your IP location, coordinates and map.
- Live location: follow your position on a map with watchPosition.
- VPN leak test: check whether WebRTC or DNS reveals your real IP.
- GPS coordinates: your latitude and longitude in every format.
More Tools