Home>
Contents

This articleI am trying to deploy AWS with reference to, but HTTP ERROR 500 has occurred.
I searched and tried various things on the net, but I couldn't solve it and I was stuck. I want to borrow your wisdom.

● What I tried and investigated
When I checked the Unicorn log, "app error: Missing"secret_key_basefor'production' environment, set this string withrails credentials: edit(ArgumentError) ", and when I looked it up, I found that the cause was that access_key_id and secret_access_key were not entered in credentials.yml.enc.
I had set IAM before, so I created a new access key and secret key there, executed the "EDITOR = vim rails credentials: edit" command on the server side, and wrote the access key and secret key.
Also, master.key is different from the development environment, so I edited master.key in the production environment with vim and copied the one described in the development environment.
I was hoping that the error would be resolved by doing so far, but the same "app error: Missing"secret_key_basefor'production' environment, set this string withrails credentials: edit(Argument Error) "message is displayed. Where is the error occurring?

Unicorn.log
E, [2020-10-22T12: 58: 55.067352 # 28094] ERROR-: app error: Missing `secret_key_base` for'production' environment, set this string with` rails credentials: edit` (ArgumentError)
E, [2020-10-22T12: 58: 55.067432 # 28094] ERROR-: /home/taishi/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-5.2.4.3 /lib/rails/application.rb:585: in `validate_secret_key_base'
E, [2020-10-22T12: 58: 55.067449 # 28094] ERROR-: /home/taishi/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-5.2.4.3 /lib/rails/application.rb:432:in `secret_key_base'
E, [2020-10-22T12: 58: 55.067461 # 28094] ERROR-: /home/taishi/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-5.2.4.3 /lib/rails/application.rb:253:in ʻenv_config'
E, [2020-10-22T12: 58: 55.067523 # 28094] ERROR-: /home/taishi/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-5.2.4.3 /lib/rails/engine.rb:712:in `build_request'
E, [2020-10-22T12: 58: 55.067538 # 28094] ERROR-: /home/taishi/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-5.2.4.3 /lib/rails/application.rb:608:in `build_request'
E, [2020-10-22T12: 58: 55.067548 # 28094] ERROR-: /home/taishi/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-5.2.4.3 /lib/rails/engine.rb:523:in `call'
E, [2020-10-22T12: 58: 55.067558 # 28094] ERROR-: /home/taishi/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/unicorn-5.4.1 /lib/unicorn/http_server.rb: 606: in `process_client'
E, [2020-10-22T12: 58: 55.067574 # 28094] ERROR-: /home/taishi/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/unicorn-5.4.1 /lib/unicorn/http_server.rb:701: in `worker_loop'
E, [2020-10-22T12: 58: 55.067603 # 28094] ERROR-: /home/taishi/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/unicorn-5.4.1 /lib/unicorn/http_server.rb:549:in `spawn_missing_workers'
E, [2020-10-22T12: 58: 55.067617 # 28094] ERROR-: /home/taishi/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/unicorn-5.4.1 /lib/unicorn/http_server.rb:142:in `start'
E, [2020-10-22T12: 58: 55.067628 # 28094] ERROR-: /home/taishi/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/unicorn-5.4.1/bin/unicorn_rails: 209: in `<top (required)>'
E, [2020-10-22T12: 58: 55.067639 # 28094] ERROR-: /home/taishi/.rbenv/versions/2.7.1/bin/unicorn_rails:23:in `load'
E, [2020-10-22T12: 58: 55.067649 # 28094] ERROR-: /home/taishi/.rbenv/versions/2.7.1/bin/unicorn_rails:23:in `<main>'
  • Answer # 1

    "App error: Missing secret_key_base for'production'environment, set this string with rails credentials: edit (ArgumentError)", and when I looked it up, it was because access_key_id and secret_access_key were not entered in credentials.yml.enc. I understood.

    No, credentials.yml.enc or secrets.yml (or environment variables)SECRET_KEY_BASE) Tosecret_key_baseThe problem is that is not found.

    in credentials.yml.encsecret_key_baseThe reason why an error occurs even though I have set is not clear from the situation presented.
    There may be some bugs or invisible characters, or there may be a problem with the usage of credentials.yml.enc.

    By the way, in the reference textsecrets.ymlIt is set to.