0

I have an Rails app on Heroku and, for some reason, it cannot connect to my production database when I deploy it. Seems to be ignoring anything I enter on database.yml.

This database is not an add-on on this specific Heroku app, but on a different one. However, the database connection details below are correct.

default: &default
  adapter: sqlite3
  pool: 5
  timeout: 5000

development:
  <<: *default
  database: db/development.sqlite3

test:
  <<: *default
  database: db/test.sqlite3

production:
   adapter: postgresql
   encoding: unicode
   database: asdfasdfasdf # [HIDDEN]
   pool: 5
   host: ec2-xxx-xx-xxx-xx.compute-1.amazonaws.com
   username:  asdfasdfasdf # [HIDDEN]
   port:       5432
   password:  asdfasdfasdfasdfasdfasdf # [HIDDEN]
   timeout: 5000

2 Answers2

2

Heroku ignore the database.yml file properties. You need to set DATABASE_URL as environmental value.

ENV["DATABASE_URL"]= postgres:username:password@host/db_name

See also: Heroku postgresql configuration.

Masudul
  • 21,823
  • 5
  • 43
  • 58
0

Set DATABASE_URL with below command

heroku  config:addDATABASE_URL='postgres://asdfasdfasdf:asdfasdfasdf@ec2-xxx-xx-xxx-xx.compute-1.amazonaws.com:5432/asdfasdfasdf'
Sanjiv
  • 813
  • 6
  • 13