Search code examples
geopy

geopy.exc.GeocoderInsufficientPrivileges: HTTP Error 403: Forbidden


Im trying to use geopy to get the lat/long but it throws a http 403 forbidden error.

from geopy.geocoders import Nominatim
geolocator = Nominatim()
addr = '350 5th Ave, New York, NY 10118'
location = geolocator.geocode(addr)
print location

It was all working fine for last few days.

    raise ERROR_CODE_MAP[code](message)
geopy.exc.GeocoderInsufficientPrivileges: HTTP Error 403: Forbidden

Solution

  • I probably fixed the problem. According to this documentation https://geopy.readthedocs.io/en/stable/#nominatim you need to specify user-agent for each app that is using Nominatim

            geolocator = Nominatim(user_agent="name_of_your_app")