I am brand new to render. I have two services, an app train_rails_app and a Postgres database called train-rails-database. The app is a rails app using a render.yaml file to deploy.
My understanding is that on render I need both services for the database to persist?
The app has deployed but I am getting a database connection error when trying to sign up.
[7b91e1b2-cdf3-4d36-b49c-c0b99f163edf] ActiveRecord::ConnectionNotEstablished (connection to server on socket “/var/run/postgresql/.s.PGSQL.5432” failed: No such file or directory
I assume I don’t have something set up correctly in the app for the database:
My database.yml file:
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch(“RAILS_MAX_THREADS”) { 5 } %>
host: <%= ENV[‘DATABASE_HOST’] %>
port: 5432
username: <%= ENV[‘DATABASE_USER’] %>
password: <%= ENV[‘DATABASE_PASSWORD’] %>
database: <%= ENV[‘DATABASE_NAME’] %>
production:
<<: *default
database: <%= ENV[‘DATABASE_NAME’] %>
username: <%= ENV[‘DATABASE_USER’] %>
password: <%= ENV[‘DATABASE_PASSWORD’] %>
host: <%= ENV[‘DATABASE_HOST’] %>
port: 5432
My render.yaml file:
services:
- type: web
name: train-rails-app
env: ruby
region: ohio
buildCommand: bundle install && bundle exec rake assets:precompile
startCommand: bundle exec rails server -b 0.0.0.0 -p 3000
migrateCommand: bundle exec rails db:migrate
envVars:- key: RAILS_MASTER_KEY
sync: false - key: WEB_CONCURRENCY
value: 2 # sensible default - key: DATABASE_URL
value: postgres://train_rails_y3_user:actual password@actual host value:5432/train_rails_y3 - key: DATABASE_USER
value: train_rails_y3_user - key: DATABASE_PASSWORD
value: actual password - key: DATABASE_HOST
value: actual host value - key: DATABASE_NAME
value: train_rails_y3
- key: RAILS_MASTER_KEY
databases:
- name: train-rails-database
databaseName: train_rails_y3
user: train_rails_y3_user
password: actual password
region: ohio
I have change the env variable names. Should all the ENV just be in the service ENVs or in the YAML file. Any help here would be greatly appreciated!