Using Postgres on Heroku with Play 2

26 Dec 2014

It's a bit of a dance because Heroku set the environment variable `DATABASE_URL` that contains username and password. So, you will need to force the driver to read username and password from the URL. Here are the steps:

  1. Remove `db.default.userand ``db.default.password` fromapplication.conf``.
  2. Modify the url to contain username and password for running locally: `db.default.url="postgres://root:root@localhost:5432/tanin"`
  3. Create Procfile that looks like this: `web: target/universal/stage/bin/tanin-scala -Dhttp.port=$PORT -Ddb.default.url=$DATABASE_URL`

And that's it.


Please note that the presence of `db.default.userand ``db.default.password``` make the driver read the username and password from those variables; It will not work with Heroku.

Give it a kudos