Rey Libutan
Rey Libutan

Reputation: 5314

Heroku - FATAL: password authentication failed for user <>

First of all, I created PostgreSQL DB in Heroku. I manually created my DB/schema/tables through pgAdmin remote access. I know I succeeded since it updated my row limit.

Now, I am deploying a Spring Boot application. No DB props/credentials are found in my application.properties file since I am supposed to do this in Heroku Config Vars. For example, my DB username is janxgspmlpjgbn

Project builds successfully, however, in the logs I see that it has this exception.

2016-09-28 16:12:31.184 [ERROR] org.apache.juli.logging.DirectJDKLog.log:181 - Unable to create initial connections of pool.
2016-09-28T16:12:31.185772+00:00 app[web.1]: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "u24453"

Question

Why does it fail for the user u24453 (by the way this user changes every time I redeploy) when in my Config Var, I typed the user janxgspmlpjgbn?

Edit

Here's how my Config Vars look right now: enter image description here

Upvotes: 2

Views: 2871

Answers (1)

codefinger
codefinger

Reputation: 10318

u24453 is probably the OS user name (the one Heroku creates for your app as it runs on Ubuntu Linux).

I believe the Postgres Driver will use the OS username as your DB username by default (if a username is not provided). Thus, I suspect the DB username is not getting into the configuration properly.

In your application.yml you should have this:

spring:
  datasource:
    url: ${JDBC_DATABASE_URL}
    username: ${JDBC_DATABASE_USERNAME}
    password: ${JDBC_DATABASE_PASSWORD}

For more info see Connecting to Relational Databases on Heroku with Java

Upvotes: 4

Related Questions