node package manager


Auto updating maxmind GeoIP lookup for free and paid maxmind accounts and optional cloudflare fallback


Auto updating maxmind GeoIP lookup for free and paid maxmind accounts with optional cloudflare fallback. Leveringing the excellent node-maxmind package, maxminded manages regular data updates and provides an ultrafast geoip lookup fallback via geos-major and CloudFlare headers when there is a maxmind IP lookup miss.

npm install maxminded

Drop in compatible with node-maxmind when using free Maxmind GeoLiteCity data.

maxmind = require('maxminded');
maxmind.init('GeoLiteCity.dat');             // local init data & free Wednesday updates 
location = maxmind.getLocation(''); // City/Location lookup 

Start with local free data, until initial paid data is loaded and then do paid data updates every Wednesday.

maxminded = require('maxminded');
    initLoad:    'GeoLiteCity.dat', // immediately initialize with local free data 
    memoryCache: true,              // use memory cache for geo lookups 
    license:     'S0meK3yIdHere',   // paid MAXMIND license key 
    start:       true               // begin initial paid date update 
}, function(err) {                  // callback when re-initialized with paid data  
    if (err) console.log(err)
geo = maxminded.getLocation(''); 

Use paid data and initialize doing updates every Wednesday and fallback to CloudFlare data until initial download and initialize completes or when maxmind.getLocation() fails to match an ip.

This requires CloudFlare to be enabled for your domain so the cf-country header will be populated.

maxminded = require('maxminded');
    start:       true               // begin initial free date update 
}, function(err) {                 
    if (err) console.log(err)
geo = maxmind.getLocation('', req.headers); // pass in request headers for fallback 

In this example, getLocation() will return undefined until the initial data is loaded and there is no cf-country header

    cronTime:    '00 30 03 * * 3', // update every Wednesday at 3:30am 
    dest:        '/tmp/',          // where geo updates are stored 
    retries:     5,                //  
}, function(err) {                 // callback when maxmind.init() occurs 

For additional parameter details see: node-maxmind and maxmind-loader and node-cron

A bonus of using maxminded is that your geo data doesn't need to be pushed to your PaaS with your code deploy. The geo ip data can be pulled directly from maxmind in compressed form when your application launches.

maxminded.init({start: function() {
    var geo = maxminded.getLocation(''); // GeoCityLite loaded w/weekly updates  


Development Dependencies: