Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my Play/Heroku/Postgres deployment fail with a password error?

I'm getting started with the Play Framework, and have a toy app that runs locally using an H2 in-memory database. My application.conf file looks like this:

db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:mem:my-app-db"
db.default.user=sa
db.default.password=""

However when I try to deploy the app to Heroku, using the Postgres database that they provide, the deployment fails:

org.postgresql.util.PSQLException: FATAL: password authentication failed for user "sa"
2013-05-17T01:22:18.982766+00:00 app[web.1]:    at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
2013-05-17T01:22:18.982827+00:00 app[web.1]:    at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125)
2013-05-17T01:22:18.983634+00:00 app[web.1]:    at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:112)
2013-05-17T01:22:18.982915+00:00 app[web.1]:    at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
2013-05-17T01:22:18.982665+00:00 app[web.1]:    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:108)
2013-05-17T01:22:18.982981+00:00 app[web.1]:    at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:22)
2013-05-17T01:22:18.983376+00:00 app[web.1]:    at java.sql.DriverManager.getConnection(DriverManager.java:200)

My Procfile is exactly as described in the getting started guide:

web: target/start -Dhttp.port=${PORT} ${JAVA_OPTS} -DapplyEvolutions.default=true -Ddb.default.driver=org.postgresql.Driver -Ddb.default.url=${DATABASE_URL} 
like image 748
Andrew Swan Avatar asked Mar 24 '23 22:03

Andrew Swan


1 Answers

The problem was that these two properties were interfering with Postgres:

db.default.user=sa
db.default.password=""

(Postgres already has the username and password in the URL, as you can see if you run heroku config and look at the DATABASE_URL property.)

When I commented out the above two lines and pushed to Heroku again, Postgres worked properly, and H2 still worked locally.

like image 185
Andrew Swan Avatar answered Apr 19 '23 23:04

Andrew Swan