2

I have an Heroku account and I created an app and an Heroku-Postgres database. I already commited the app to the Heroku cloud, but I cannot access to the DB that I created.

I'm using play, and when i connect my project in my local DB, the application.conf configurations are:

db.default.driver=org.postgresql.Driver
db.default.url="jdbc:postgresql://localhost:5432/postgres"
db.default.user=postgres
db.default.password=password

And run my server locally and it works fine.

Before I upload my app to Heroku I changed this file to access my Heroku-Postgres DB:

db.default.driver=org.postgresql.Driver db.default.url="jdbc:postgresql://url:5432/database_name?user=name&password=pass&ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory"

The user and password fields are no longer needed. I've already created a file in the root of my project named "Procfile" that has:

web: target/universal/stage/bin/playsense -Dhttp.port=${PORT} -DapplyEvolutions.default=true -Ddb.default.driver=org.postgresql.Driver -Ddb.default.url=${DATABASE_URL}

I discovered this on the documentation. I don't understand why it doesn't connect to my DB. I used pgAdminIII with the DB credentials and it works fine.

It's something missing/wrong and I don't know what.

Can someone help me?

1 Answer 1

1

You probably need to unset the db.default.user and db.default.password config params when running on Heroku. But I'm not sure of an easy way to do that. So what I usually do is to not set them in the conf/application.conf and instead I do something like:

db.default.driver=org.postgresql.Driver
db.default.url="postgres://postgres:password@localhost:5432/postgres"
db.default.url=${?DATABASE_URL}
#db.default.user=postgres
#db.default.password=password

That provides a default db.default.url but overrides it with the DATABASE_URL env var if it is set.

Sign up to request clarification or add additional context in comments.

2 Comments

How do i debug this on Heroku, to see if the it's nothing wrong with my code. Even with this configurations, it's not accessing my DB. Maybe it's something else. Locally, everything works, running play on debug mode on my computer and accessing my pgAdmin local DB.
Use heroku logs to see any logged errors with your app on Heroku.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.