Heroku Database Connection Properties
I also had the issue with the FATAL: no pg_hba.conf entry for host
error message.
I solved the connection issue to my Heroku Postgres database by adding the following to my JDBC string: &ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory
.
Example
jdbc:postgresql://host:port/database?user=username&password=secret&ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory
You will need the SSL option only if SSL is enabled for your Postgres database (which is the default).
Hint
If you want to check your database connection properties, then just run the following command with the Heroku Toolbelt: heroku pg:info --app your-heroko-appname
(make sure that you have Postgres insalled to run this command in your terminal)
The pg:info
command will also tell you that sslmode
is set to require
.
To test the database connection I recommend SQL Power Architect as it is the tool which I was using to check my solution.
Heroku provides this information for connecting from external sources:
https://devcenter.heroku.com/articles/heroku-postgresql#external-connections-ingress
The second error message indicates PostgreSQL is not configured to accept the connection you're trying to make. Given the information Heroku provides, a good guess is that you're not connecting with SSL. Try to enable that on your connection.
Here are instructions for using SSL with Navicat: http://mirror.navicat.com/manual/online_manual/en/navicat/rv_manual/ClientCert.html.
This may be helpful in configuring Intellij to use SSL: https://devcenter.heroku.com/articles/connecting-to-relational-databases-on-heroku-with-java#connecting-to-a-database-remotely.