Missing encryption key to decrypt file with Ruby / Rails Origin: Application & API Last updated 5 Nov 2026

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']

Rails needs config/master.key or RAILS_MASTER_KEY to read credentials, and neither exists.

Exact message you may see 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']ArgumentError: Missing encryption key to decrypt file withActiveSupport::EncryptedFile::MissingKeyError: Missing encryption key to decrypt file withMissing encryption key to decrypt file with config/credentials.yml.encRAILS_MASTER_KEY missing
Seen on: Ruby Docker

Meaning

master.key isn't committed (by design). Provide it via the environment variable in production/CI (RAILS_MASTER_KEY=...) or place the file in config/ on the server. For Docker builds pass it as a secret, or use SECRET_KEY_BASE_DUMMY=1 for assets:precompile (Rails 7.1).

Common causes

  • config/master.key missing (not in git)
  • RAILS_MASTER_KEY unset on the server/CI
  • Docker build without the key
  • Precompiling assets without credentials
  • New developer without the key

⚡ Quick fix

  1. Set RAILS_MASTER_KEY in the environment/secrets manager
  2. For precompile: SECRET_KEY_BASE_DUMMY=1 bin/rails assets:precompile
  3. Share the key securely with teammates

Detailed fix by platform

Docker

  1. docker run -e RAILS_MASTER_KEY=$(cat config/master.key) app

How to diagnose

  1. Key — File or ENV?
  2. Environment — Prod/CI?
  3. Build — Dummy key?

🔧 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):

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 secret_key_base for 'production' environment — Rails: ArgumentError: Missing `secret_key_base` for 'production' environment, set this string with `bin/rails credentials:edit` (Ruby / Rails)Missing secret_key_ba…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 e…

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.