(Created on )

Puppeteer: Invalid longitude '{value}': precondition -180 <= LONGITUDE <= 180 failed.

Longitude is outside the accepted -180 to 180 range.


Longitude is outside the accepted -180 to 180 range.

Error message

Invalid longitude '{value}': precondition -180 <= LONGITUDE <= 180 failed.

{value} is replaced by the value shown in your error message.

How this error happens

longitude must be -180 to 180 degrees. Invalid coordinates are rejected instead of being normalized.

The snippets use an open Puppeteer page named page.

await page.setGeolocation({
    latitude: 48.8566,
    longitude: 181,
    accuracy: 10,
});

How to fix

Validate the input and pass a value within the accepted range.

await page.setGeolocation({
    latitude: 48.8566,
    longitude: 2.3522,
    accuracy: 10,
});

Things to keep in mind

A valid location override does not grant geolocation permission. Grant that permission separately for the origin being tested.

All Puppeteer errors

Keep Reading

Puppeteer Guides

All Guides →