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.
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 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
export SECRET_KEY_BASE=$(bin/rails secret)(store it securely)- Or ship
credentials.yml.enc+RAILS_MASTER_KEY SECRET_KEY_BASE_DUMMY=1for precompile only
Detailed fix by platform
Rails
bin/rails secretgenerates a 128-hex-character key
How to diagnose
- Variable — Set in prod?
- Credentials — Readable?
- 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:
Similar errors
- 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
- ActiveRecord::AssociationTypeMismatch Rails: ActiveRecord::AssociationTypeMismatch: User(#1234) expected, got "42" which is an instance of String(#5678)
- ActiveRecord::ConnectionNotEstablished Rails: ActiveRecord::ConnectionNotEstablished: No connection pool for 'ActiveRecord::Base' found
Most viewed in Ruby / Rails
- ActiveRecord::PendingMigrationError Rails: ActiveRecord::PendingMigrationError — Migrations are pending. To resolve this issue, run: bin/rails db:migrate
- ActionController::InvalidAuthenticityToken Rails: ActionController::InvalidAuthenticityToken (Can't verify CSRF token authenticity)
- undefined method for nil Ruby: NoMethodError: undefined method `x' for nil (nil:NilClass)
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 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.
Report a correction or suggest an improvement
Last updated 5 Nov 2026