Learnings
New Learning
About The App
Hire Me
Writing Samples
Edit Learning
Title
Body
Context: I encountered runtime errors (`ActiveRecord::ConnectionNotEstablished`) trying to connect via local socket (`/var/run/postgresql/.s.PGSQL.5432`). Despite `config/database.yml` being configured for `DATABASE_URL`, Rails was not running in the `production` environment, causing it to default to socket connections defined elsewhere in `database.yml` (likely development). Cause 1: The Start Command initially included `-e ${RACK_ENV:-development}` or similar, overriding the production setting. Cause 2: The `RAILS_ENV` environment variable was missing or incorrect in Render. Cause 3: Puma reported `Environment: development` or `deployment` even with `RAILS_ENV=production` set, suggesting `RACK_ENV` might take precedence or another override was present. Resolution: * I changed the Start Command to `bundle exec puma -C config/puma.rb` (removing explicit `-e`). * I explicitly added both `RAILS_ENV=production` and `RACK_ENV=production` environment variables in Render's UI. Learning: I learned to ensure the Rails environment is correctly set to `production` on the deployment server via `RAILS_ENV` (primary) and potentially `RACK_ENV` environment variables. I need to verify the environment Puma/Rails reports in the logs and check the Start Command for overrides.
Learned on (YYYY-MM-DD)
Tags
Add comma-separated tags. They help filter learnings later.
Back to Learnings