question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

geocoder.ip('me').country returns None

See original GitHub issue

Thanks for a great package that’s worked in my system, Mycodo, for over a year without an issue.

Recently (past week or so), I’ve been having the country query return None, from systems around the world.

import geocoder
print("Country='{return}'".format(return=geocoder.ip('me').country))
$ python ./test_geocoder.py
Country='None'

I haven’t dug enough into geocoder to know exactly how to debug this.

Is this a known issue? Is there anything I can do to help?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
DenisCarrierecommented, Jul 7, 2017

@kizniche There’s two providers that offer reverse IP lookups, maxmind & ipinfo. When you use geocoder.ip('me') it’s actually using http://ipinfo.io/ for it’s internal requests.

Seems like geocoder.ip('me') is broken if you provide ‘me’ or blank.

>>> geocoder.ip('me')
>>> g.debug()
{}
{
    "status": "Cannot GET //json\n", 
    "status_code": 400, 
    "provider": "ipinfo", 
    "ok": false, 
    "encoding": "utf-8"
}

Strange that it use to work before, maybe it was always a “bug” however their server accepted that HTTP request.

Solution: Change geocoder.ip('me') HTTP request from http://ipinfo.io//json => http://ipinfo.io/json

0reactions
DenisCarrierecommented, Jul 13, 2017

👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

geocoder.ip('me') work locally but not on heroku - Stack Overflow
I am using Django and need to get the user's current location, so I use geocoder.ip('me') . It works fine locally, but after...
Read more >
IP Info.io — geocoder 1.38.1 documentation - Read the Docs
Use the IPInfo.io IP lookup API to quickly and simply integrate IP geolocation ... To retrieve your own IP address, simply have ''...
Read more >
Geocoder Documentation - Read the Docs
g = geocoder.ip('me') ... As for now, Geocoder always returns one result: the best match ... print([g.address, g.country, g.latlng]).
Read more >
Advice on geocoding IP addresses - GIS Stack Exchange
I downloaded their database and used that to process my data. It is amazing that it is free for non-commercial use! – djq....
Read more >
geocoder-php/stack-geo-ip - Packagist
By wrapping the GeoIP middleware around it using the StackBuilder, if the IP address can be matched to a country, the X-Country header...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found