Build failure, unable to download the MaxMind geolocation database

AI-generated summary

A user, KGrzeg, encountered a build failure while setting up Discourse on a DigitalOcean VPS, with the installer freezing during assets:precompile. The error traced back to a 403 Forbidden error when trying to download the MaxMind geolocation database, due to the server’s IP being blocked. Falco identified the issue and suggested adding DISCOURSE_REFRESH_MAXMIND_DB_DURING_PRECOMPILE_DAYS: 365 to the app.yml file to bypass the download. This resolved the problem, and KGrzeg confirmed it worked. Falco explained that the setting should remain to prevent future failures, as the database is only updated during base image releases. codinghorror noted that the error message was unclear and should be improved.

Hi!
I installed discourse on fresh DigitalOcean machine using this instructions 2 days ago and all were fine.
Yesterday I tried to install app one more time, on new DigitalOcean machine (Ubuntu 18.03, 1GB). The VPSes are equals, but this time it didn’t works.

I ran ./discourse-setup, answered a questions and waited. My terminal freezed at line #<Thread:0x00005621595f3360@/var/www/discourse/lib/tasks/assets.rake:215 run> terminated with exception (report_on_exception is true): The only way to release terminal was to close ssh connection and reconnect.

I have only basic knowlege about linux.
Updating system with apt-get, didn’t make any difference.
I figured out, that installer hangs at task assets:precompile. The exception raise from /var/www/discourse/lib/tasks/assets.rake:227:in rescue in block (2 levels) in <top (required)>': undefined local variable or method'name' for main:Object (NameError)
The setup writes binary data to console, thats why freeze. Digging deeper i realise, that error 403 occur, but I can’t found target URL.

Anyone have any tips?

What plan were you on RAM/CPU wise?

  • 1GB of RAM
  • 1 shared vCPU 2.3GHz
  • 25GB ROM SSD

Can you put the full backtrace here? Also, do you have any custom plugins?

I ran setup in screen and recorded. Then open log with xdd. I replaced 2 chunks of binary data with <BINARY_DATA>

#<Thread:0x000055c07c7e8cf8@/var/www/discourse/lib/tasks/assets.rake:215 run> terminated with exception (report_on_exceptionis true):
/var/www/discourse/lib/tasks/assets.rake:227:in `rescue in block (2 levels) in <top (required)>':undefined local variable or method`name' for main:Object (NameError)
from /var/www/discourse/lib/tasks/assets.rake:216:in `block (2 levels) in <top (required)>' /var/www/discourse/lib/file_helper.rb:55:in `block in download':
403 Error:<BINARY_DATA> (OpenURI::HTTPError) <BINARY_DATA>
from /var/www/discourse/lib/final_destination.rb:400:in `block (3 levels) in safe_get'
from /var/www/discourse/lib/final_destination.rb:399:in `catch'
from /var/www/discourse/lib/final_destination.rb:399:in `block (2 levels) in safe_get'
from /usr/local/lib/ruby/2.6.0/net/http.rb:1518:in `block in transport_request'
from /usr/local/lib/ruby/2.6.0/net/http/response.rb:165:in `reading_body'
from /usr/local/lib/ruby/2.6.0/net/http.rb:1517:in `transport_request'
from /usr/local/lib/ruby/2.6.0/net/http.rb:1479:in `request'
from /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-mini-profiler-1.0.2/lib/patches/net_patches.rb:9:in `block in request_with_mini_profiler'
from /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-mini-profiler-1.0.2/lib/mini_profiler/profiling_methods.rb:39:in `step'
from /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-mini-profiler-1.0.2/lib/patches/net_patches.rb:8:in `request_with_mini_profiler'
from /var/www/discourse/lib/final_destination.rb:371:in `block in safe_get'
from /var/www/discourse/lib/final_destination.rb:415:in `block in safe_session'
from /usr/local/lib/ruby/2.6.0/net/http.rb:920:in `start'
from /usr/local/lib/ruby/2.6.0/net/http.rb:605:in `start'
from /var/www/discourse/lib/final_destination.rb:412:in `safe_session'
from /var/www/discourse/lib/final_destination.rb:363:in `safe_get'
from /var/www/discourse/lib/final_destination.rb:129:in `get'
from /var/www/discourse/lib/file_helper.rb:47:in `download'
from /var/www/discourse/lib/discourse_ip_info.rb:30:in `mmdb_download'
from /var/www/discourse/lib/tasks/assets.rake:218:in `block (3 levels) in <top (required)>'
from /var/www/discourse/lib/tasks/assets.rake:217:in `each'
from /var/www/discourse/lib/tasks/assets.rake:217:in `block (2 levels) in <top (required)>'

Installer make then some task without problems. At the end of process there are:

FAILED--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake assets:precompile'
failed with return #<Process::Status: pid 384 exit 1>
Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'..exec
failed with the params {"cd"=>"$home", "hook"=>"assets_precompile",
"cmd"=>["su discourse -c 'bundle exec rake assets:precompile'"]}
f534324ceedf6b1a8a5cc89f38e1c12c2418fb69c71f93f21c0dd2f5ef51483d
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one
./discourse-doctor may help diagnose the problem.

Command ./discourse-doctor don’t help. Doctor realise that app doesn’t run, try to rebuild and hangs too.
I have not installed any plugins, because i have never ran this app on this machine :frowning:

Your IP is blocked from downloading the MaxMind DB.

Edit the app.yml file and add, under the env key DISCOURSE_REFRESH_MAXMIND_DB_DURING_PRECOMPILE_DAYS: 365 and then try a rebuild.

That works! :boom::fire::tada:
Thank you very very much! Do I need to left this line in app.yml, or delete her after first succesfully call?

It will fail again as soon as you remove it because your server can’t download a newer DB.

Having it set to 365 effectively means you will get it updated when we release a new base image, which happens twice a year.

We should have a better error here for sure, that error is completely inscrutable..