I'm getting an error "ActiveSupport::MessageEncryptor::InvalidMessage". How do I fix it?

The ActiveSupport::MessageEncryptor::InvalidMessage is raised when you forgot your Rails credentials key

Written by Chris Oliver
Updated over a week ago
If you see the following error message in your deploy logs, this means you forgot to add the RAILS_MASTER_KEY environment variable to your application.
ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage
To fix this, add the RAILS_MASTER_KEY environment variable.

If your application has a config/credentials/production.key, use the contents of this file for the RAILS_MASTER_KEY.
If your application has a config/master.key, use the contents of this file for the RAILS_MASTER_KEY.

Rails first checks config/credentials and then falls back to config/master.key. Some applications have both, so you should remove the duplicate and make sure you only have one Rails credentials file in your git repository.

Was this article helpful?