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

**Code:** `Missing secret_key_base for 'production' environment` · **Category:** Ruby / Rails · **Seen on:** Ruby

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/ruby/rails-secret-key-base-missing)
