Fix Phoenix SECRET_KEY_BASE missing on seenode
Phoenix won't boot on seenode without SECRET_KEY_BASE. Generate one and set it as an environment variable.
The error
Your Phoenix app crashes on startup with something like:
ERROR!! environment variable SECRET_KEY_BASE is missing.You can generate one by calling: mix phx.gen.secretor RuntimeError: no :secret_key_base configured.
Quick fix
Phoenix needs a SECRET_KEY_BASE in production. Generate one locally:
mix phx.gen.secretSet the output as a SECRET_KEY_BASE environment variable on your service, then redeploy. Your config/runtime.exs should read it from the environment (the default generated file already does):
secret_key_base = System.get_env("SECRET_KEY_BASE") || raise "environment variable SECRET_KEY_BASE is missing."Why this happens
SECRET_KEY_BASE signs and encrypts sessions and tokens. It’s a secret, so it isn’t committed to your repo; you must supply it at runtime. Without it, Phoenix refuses to start in production.
Checklist
SECRET_KEY_BASEis set on the service and you redeployed.- The value is a real generated secret (from
mix phx.gen.secret), not a placeholder. config/runtime.exsreadsSECRET_KEY_BASEfrom the environment.