postgresqlherokuplayframeworkheroku-postgresplayframework-2.5

Not able to make postgres database call on heroku using Play Framework Application


I am build REST api using play framework 2.8 , I am able to start the application and call some service. Facing issue when trying to connecting with postgres database. Logs are below -

Error opening connection for database: {}org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host "3.87.112.32", user "abc", database "xyz", SSL off

Tried looking solution for this and foudn have to add sslmode=require in query param while connection to database.

When log the url sslmode is already mentioned.

jdbc:postgresql://abc.amazonaws.com:5432/xyz?password=1234&sslmode=require&user=xyz

I am reading this property from heroku env variable JDBC_DATABASE_URL for obtaining database connection.


Solution

  • This issue can be fixed by adding addition query parameters apart from sslmode=require which are ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory after adding this the new URL become jdbc:postgresql://abc.amazonaws.com:5432/xyz?password=1234&sslmode=require&user=xyzssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory