MaxMind 401 error -- have license key, can't download

Following instructions at Configure MAXMIND for reverse IP lookups, I think I’m set up correctly, but I’m getting a 401 error for the MaxMind DB downloads.

I’m on a standard install, self-hosted & current.
I created an account at MaxMind, and added a new license key.

I edited the ENV section of app.yml to:

  ## The maxmind geolocation IP address key for IP address lookup
  ## see https://meta.discourse.org/t/-/137387/23 for details
  DISCOURSE_MAXMIND_ACCOUNT_ID: [my account ID]
  DISCOURSE_MAXMIND_LICENSE_KEY: [my license key]

…then ran ./launcher rebuild app

On rebuild, these “401 Unauthorized” errors were logged:

MaxMind database GeoLite2-City download failed. : OpenURI::HTTPError : 401 Error
MaxMind database GeoLite2-ASN download failed. : OpenURI::HTTPError : 401 Error

(… and of course no DB files got to my /var/www/discourse/vendor/data)

Per this suggestion I used a command found at the MaxMind Developer Portal – with the very same credentials – to directly download a database:

curl -O -J -L -u [my account ID]:[my license key] \
'https://download.maxmind.com/geoip/databases/GeoLite2-City/download?suffix=tar.gz'

…which worked fine.

What might I be missing to cause a 401 when connecting from Discourse?

1 like

Looks like this topic didn’t find any takers! Were you able to figure it out?

Thanks for checking in! No, I haven’t figured it out. I had the same result after a subsequent update+rebuild. Not sure what to look into… :person_shrugging:

Hey sorry this topic is languishing. I don’t have alot of experience with this myself. Are you experiencing problems with IP lookups in the review queue? Maybe this is just a warning that you don’t need to worry about? :thinking:

I don’t have much of a review queue, but without the MaxMind DB I wouldn’t be able to do a location lookup for a user if I needed to research some issue, and…

Curious to know if others have seen an issue connecting to MaxMind for the DB downloads, or if it’s just me. Seems like something that could go unnoticed until you need it.

FWIW Mine still seems to work okay. :person_shrugging:

Unfortunately I don’t know what the difference is. :thinking:

1 like

It seems to be working on a site that I just rebuilt.

My only guess is that you somehow have those settings in the wrong place (and from what you’ve included, that seems improbable).

Does this show you your Maxmind creds like this?

root@figgy:/var/discourse# ./launcher enter app
root@figgy-spm:/# set|grep MAXM
DISCOURSE_MAXMIND_ACCOUNT_ID=12345
DISCOURSE_MAXMIND_LICENSE_KEY=mycoolkey
root@figgy-spm:/# grep maxm /var/www/discourse/config/discourse.conf
maxmind_license_key = 'mcoolkey'
maxmind_account_id = '12345'

So you’d

./launcher enter app
set|grep MAXM
grep maxm /var/www/discourse/config/discourse.conf

also you can check that Rails has them (still inside the container):

rails c

and then

GlobalSetting.maxmind_account_id
GlobalSetting.maxmind_license_key

Hopefully, somehow you don’t have your stuff in the env: section of the app.yml (though your pasted comments suggest that they are in the right place), which would be easy to fix.

3 likes

Thank you Jay – your troubleshooting steps above all checked out, so while I was in there, I just cleared things out and started over. This time Discourse downloaded the MaxMind dbs, and I can now geo-resolve IP addresses.

All I can guess is an oddball glitch with my MaxMind account, or maybe a copy/paste error with the original license key.

Your efforts ruled out other issues, so I’ll mark that as the solution. :white_check_mark:

3 likes