thecodecrate / city-state

Simple ruby gem to create form lists with cities and states
MIT License
306 stars 135 forks source link

Failed to open TCP connection to geolite.maxmind.com:80 (getaddrinfo: No address associated with hostname) (SocketError) #42

Closed f4-nikita closed 4 years ago

f4-nikita commented 4 years ago

Hello. It seems maxmind stoped support of this DB url. So CS.update went to endless loop trying to access url.

If someone had issue with endless cycle of errors - remove CS.update from your codebase. Next step will be fixing url inside this lib and creating error handler to prevent errors in future with accessing to DB's.

Thanks.

f4-nikita commented 4 years ago

Update: https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-geolite2-databases/

hantuzun commented 4 years ago

This gem comes with a DB of 5 years old. It is supposed to be able to update it, but Maxmind disabled their service of freely publishing their location DB.

The latest Maxmind DB with free license* is from 24 December 2019 and it is available at: https://web.archive.org/web/20191227183011/https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country-CSV.zip

It has 120,707 entries compared to 87,007 entries in the gem. Could we possibly update it manually?

*Creative Commons Attribution-ShareAlike 4.0 International License 6

loureirorg commented 4 years ago

I have updated this library to a new version: 0.1.0.

You can update the database with this command:

CS.set_license_key('MY_KEY')
CS.update

MY_KEY is your license key that you get for free by signing up on MaxMind.

Alternatively, you can manually download the GeoLite2 City file and use it with:

CS.set_maxmind_zip_url('/home/john/GeoLite2-City-CSV_20200324.zip')
CS.update

Or use an alternative URL location:

CS.set_maxmind_zip_url('https://example.com/GeoLite2-City-CSV_20200324.zip')
CS.update

I have also updated the README file to reflect these new changes. I also added a mechanism to rename countries/states/cities as well as to suppress or to add missing countries/states/cities.

Thank you for bringing this to my attention.

hantuzun commented 4 years ago

Thanks a lot @loureirorg!

I use your gem in https://pandemicvolunteers.org/ -- it made my job much easier!