Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

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? Thanks in advance!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
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. – Nunovsky Mar 28 '14 at 15:42
    
Use heroku logs to see any logged errors with your app on Heroku. – James Ward Mar 28 '14 at 18:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.