Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insufficient Priveleges for Nominatim #112

Closed
solumos opened this issue Mar 17, 2015 · 22 comments
Closed

Insufficient Priveleges for Nominatim #112

solumos opened this issue Mar 17, 2015 · 22 comments

Comments

@solumos
Copy link

solumos commented Mar 17, 2015

When using Nominatim, we get an geopy.exc.GeocoderInsufficientPrivileges exception, even though Nominatim should not require account credentials:

>>> geolocator = Nominatim()
>>> geolocator.geocode("Washington, DC", timeout=10) 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/geopy/geocoders/osm.py", line 191, in geocode
    self._call_geocoder(url, timeout=timeout), exactly_one
  File "/usr/local/lib/python2.7/dist-packages/geopy/geocoders/base.py", line 147, in _call_geocoder
    raise ERROR_CODE_MAP[code](message)
geopy.exc.GeocoderInsufficientPrivileges: HTTP Error 403: Forbidden

Can anyone else confirm?

@carolinux
Copy link

yes, also got that

@solumos
Copy link
Author

solumos commented Mar 17, 2015

Perhaps the Error 403 is due to requests being blocked. I found this post suggesting that the usage policy is being violated. Maybe an HTTP Referer or User-Agent is necessary, long-term?

@kevinvanleer
Copy link

This issue seems to be caused by OSM changing the view box parameter from 'view_box' to 'viewbox'. I verified this by printing the log message from geopy with the geocode URL, copying it into a browser and changing it. Then I changed osm.py on my system, replacing 'view_box' with 'viewbox' in all instances. I have a branch with the change that I can push.

@solumos
Copy link
Author

solumos commented Mar 26, 2015

It looks like OSM added backwards compatibility for the 'view_box' parameter.
viewbox
view_box

@solumos solumos closed this as completed Mar 26, 2015
@tobiz
Copy link

tobiz commented Apr 13, 2016

I've started getting this error today from my program 13th Apr 2016, I didn't get it a few days ago and I've changed nothing. Also tested this from the command line running simple examples and get same result. I've now updated to geopy 1.11.0 from 1.10.0 and same result.
File "/usr/local/lib/python2.7/dist-packages/geopy/geocoders/osm.py", line 193, in geocode
self._call_geocoder(url, timeout=timeout), exactly_one
File "/usr/local/lib/python2.7/dist-packages/geopy/geocoders/base.py", line 158, in _call_geocoder
raise ERROR_CODE_MAPcode
geopy.exc.GeocoderInsufficientPrivileges: HTTP Error 403: Forbidden

geopy 1.11.0 looks like it has the view_box/viewbox fix so it's not that.

@Jeffkrop
Copy link

This started happening to me today also. I posted it here http://stackoverflow.com/questions/36599584/geopy-error-and-timeout
with no luck yet. I am only calling one location in a script for a python class.

@tobiz
Copy link

tobiz commented Apr 13, 2016

I changed from Nominatim() to geopy.geocoders.GoogleV3() and it now works; this may help someone find the problem.

@Jeffkrop
Copy link

tobiz can you post some code?

@Vixen25
Copy link

Vixen25 commented Apr 13, 2016

same here! It happened yesterday to me, and it still doesn't work ... any idea? I can't switch to google geocoded since I'm reverse-geocoding and they provide different addresses format (I should change my whole database)

@tobiz
Copy link

tobiz commented Apr 13, 2016

The code is self explanatory (I hope!)

The exception code was added to find out what was going wrong - it just
confirmed what I knew but it helped me to change the code calling
get_coords to get the values I wanted anyway (the geocode option is
useful but not essential).

After some research I found there are other geocoders so tried GoogleV3
and the problem has gone away. BTW, tried both 'http' & 'https', same result.

GeocodeFarm also works.

def get_coords(address):
try:

geolocator = Nominatim(timeout=3, scheme='http') # Nominatim

seems to have stopped working, see github geopy
geolocator = geopy.geocoders.GoogleV3(timeout=3)
try:
location = geolocator.geocode(address, timeout=3,
exactly_one=True) # Only 1 location for this address
if location == None:
print "Geocoder Service timed out or Airfield: ",
address, " not known by geocode locator service. Check settings"
return False
ele = geocoder.elevation(address)
print "Geolocator worked"
return location.latitude, location.longitude, ele.meters
except ERROR_CODE_MAP[400]:
print " ERROR_CODE_MAP is: ", ERROR_CODE_MAP[400]
except ERROR_CODE_MAP[401]:
print " ERROR_CODE_MAP is: ", ERROR_CODE_MAP[401]
except ERROR_CODE_MAP[402]:
print " ERROR_CODE_MAP is: ", ERROR_CODE_MAP[402]
except ERROR_CODE_MAP[403]:
print " ERROR_CODE_MAP is: ", ERROR_CODE_MAP[403]
except ERROR_CODE_MAP[407]:
print " ERROR_CODE_MAP is: ", ERROR_CODE_MAP[407]
except ERROR_CODE_MAP[412]:
print " ERROR_CODE_MAP is: ", ERROR_CODE_MAP[412]
except ERROR_CODE_MAP[413]:
print " ERROR_CODE_MAP is: ", ERROR_CODE_MAP[413]
except ERROR_CODE_MAP[414]:
print " ERROR_CODE_MAP is: ", ERROR_CODE_MAP[414]
except ERROR_CODE_MAP[502]:
print " ERROR_CODE_MAP is: ", ERROR_CODE_MAP[502]
except ERROR_CODE_MAP[503]:
print " ERROR_CODE_MAP is: ", ERROR_CODE_MAP[503]
except ERROR_CODE_MAP[504]:
print " ERROR_CODE_MAP is: ", ERROR_CODE_MAP[503]
return False
except GeocoderTimedOut as e:
print "Geocoder Service timed out for Airfield: ", address

return False

Hope that helps you solve your problem; if not, interesting!

@Jeffkrop
Copy link

Thank you. It returns less information for the Address but it will have to do for now.

@daviddunne
Copy link

I have started getting the same issue yesterday myself, Im handling the exception by using a Google geolocator as a backup for now.

@edwin34
Copy link

edwin34 commented Feb 25, 2018

program
error403

Issue still persists?

@psawamura
Copy link

I'm also getting the same error.

image
image

@edwin34
Copy link

edwin34 commented Mar 10, 2018

Ya issue still persists!!

@emmanuelobo
Copy link

emmanuelobo commented Apr 2, 2018

Getting the same error

GeocoderInsufficientPrivileges at /entry/create/
HTTP Error 403: Forbidden

@KostyaEsmukov
Copy link
Member

Nominatim returns HTTP Error 403: Forbidden when their ToS are violated. The reasons might be:

  1. non-unique user-agent. geopy since 1.12.0 supports passing custom user_agent like this:
>>> from geopy.geocoders import Nominatim
>>> geolocator = Nominatim(user_agent="my-application")

Actually this is stated in the docs.

  1. High volume of requests (Nominatim rate limits are quite low – no more than 1 request per second). In this case you're better off switching to another geocoding service (try MapQuest or Photon as close alternatives based on OSM).

If anyone is willing to help with adding ToS to documentation – see #268.

@renatoosousa
Copy link

same error here

@geronimogarcia3
Copy link

geronimogarcia3 commented Jul 24, 2018

changed to this and no longer got error:

geolocator = Nominatim(user_agent="my-application")

as noted to do in: https://geopy.readthedocs.io/en/stable/#nominatim

@ireneraissa
Copy link

Nominatim returns HTTP Error 403: Forbidden
I just used GoogleV3 and it works

@tobiz
Copy link

tobiz commented Jul 27, 2018

I had a similar problem; I just left it for a while and it now works again. I think the problem was at the sever end.

@Developer-felix
Copy link

0

"GeocoderInsufficientPrivileges" error - try to use 'Photon' instead of 'Nominatim'

from geopy.geocoders import Photon
geolocator = Photon(user_agent="app_name here")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests