Missing secret_key_base for 'production' environment Ruby / Rails Origin: Application & API OSI layer 7 · Application Last updated 5 Nov 2026

Rails: ArgumentError: Missing `secret_key_base` for 'production' environment, set this string with `bin/rails credentials:edit`

Production boot needs a secret_key_base to sign/encrypt cookies, and none is configured.

Exact message you may see Missing `secret_key_base` for 'production' environment, set this string with `bin/rails credentials:edit`ArgumentError: Missing `secret_key_base` for 'production' environmentMissing secret_key_base for production environmentArgumentError (Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml`)Missing secret_key_base
Seen on: Ruby

Meaning

Provide SECRET_KEY_BASE as an environment variable (generate with bin/rails secret), or set it in credentials.yml.enc with RAILS_MASTER_KEY. For asset precompilation in Docker use SECRET_KEY_BASE_DUMMY=1. Keep the same value across servers so sessions remain valid.

Common causes

  • SECRET_KEY_BASE/credentials not set in production
  • Master key missing so credentials unreadable
  • Docker precompile step without a dummy key
  • Different keys across servers
  • Env var name typo

⚡ Quick fix

  1. export SECRET_KEY_BASE=$(bin/rails secret) (store it securely)
  2. Or ship credentials.yml.enc + RAILS_MASTER_KEY
  3. SECRET_KEY_BASE_DUMMY=1 for precompile only

Detailed fix by platform

Rails

  1. bin/rails secret generates a 128-hex-character key

How to diagnose

  1. Variable — Set in prod?
  2. Credentials — Readable?
  3. Build — Dummy?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

A server is already running. Check /tmp/pids/server.pid — Rails: A server is already running (pid: 12345, file: /app/tmp/pids/server.pid). Exiting (Ruby / Rails)A server is already r…ActiveRecord::AssociationTypeMismatch — Rails: ActiveRecord::AssociationTypeMismatch: User(#1234) expected, got "42" which is an instance of String(#5678) (Ruby / Rails)ActiveRecord::Associa…ActiveRecord::ConnectionNotEstablished — Rails: ActiveRecord::ConnectionNotEstablished: No connection pool for 'ActiveRecord::Base' found (Ruby / Rails)ActiveRecord::Connect…ActiveRecord::Deadlocked: PG::TRDeadlockDetected — Rails: ActiveRecord::Deadlocked: PG::TRDeadlockDetected: ERROR: deadlock detected (Ruby / Rails)ActiveRecord::Deadloc…ActiveRecord::IrreversibleMigration — Rails: ActiveRecord::IrreversibleMigration — This migration uses remove_column without a type; db:rollback can't reverse it (Ruby / Rails)ActiveRecord::Irrever…ActiveSupport::MessageEncryptor::InvalidMessage — Rails: ActiveSupport::MessageEncryptor::InvalidMessage (credentials.yml.enc can't be decrypted — wrong master.key) (Ruby / Rails)ActiveSupport::Messag…Missing encryption key to decrypt file with — Rails: ArgumentError: Missing encryption key to decrypt file with. Ask your team for your master key and write it to config/master.key or put it in the ENV['RAILS_MASTER_KEY'] (Ruby / Rails)Missing encryption ke…Sprockets::Rails::Helper::AssetNotPrecompiled — Rails: Asset `application.js` was not declared to be precompiled in production / The asset "application.css" is not present in the asset pipeline (Ruby / Rails)Sprockets::Rails::Hel…Missing s…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.