DataGrip 2023.1 Help

Connect to Heroku Postgres without SSL validation

If you want to connect to Heroku Postgres, create a data source connection that correspond to the data source vendor. In this case, you plan to work with PostgreSQL, so you need to create a connection to PosgreSQL. DataGrip already include the necessary JDBC driver.

Heroku Postgres requires you to use SSL for the connection. But for establishing a successful SSL connection, you need a certificate that you must upload to your Heroku application. SSL certificates are specific for each Heroku application. To configure these certificates, see the article about Heroku SSL.

If you do not plan to add the certificate in the keystore, you can bypass the server validation with the NonValidatingFactory option and establish an encrypted connection.

  1. In your Heroku account, create an application with the Heroku Postgres add-on.

  2. In settings of the Heroku Postgres add-on, get the database credentials.

  3. Open data source properties. You can open data source properties by using one of the following options:

    • Navigate to File | Data Sources.

    • Press Control+Alt+Shift+S.

    • In the Database Explorer ( View | Tool Windows | Database Explorer), click the Data Source Properties icon The Data Source Properties icon.

  4. In the Data Sources and Drivers dialog, click the Add icon (The Add icon) and select PostgreSQL.

  5. At the bottom of the data source settings area, click the Download missing driver files link.

  6. In data source settings, click the Advanced tab and change values of the following properties:

    • ssl:true: to validate both the SSL certificate and verify the server.

    • sslmode:verify-ca: to verify the server by checking the certificate chain up to the root certificate stored on the client.

    • sslfactory:org.postgresql.ssl.NonValidatingFactory: to allow SSL connections without validating the server certificate.

  7. In Host, Database, User, Password, and Port fields, specify connection details that you received for the Heroku Postgres add-on.

  8. To ensure that the connection to the data source is successful, click the Test Connection link.

  9. (Optional) If you are connecting to a data source that contains a lot of databases and schemas, in the Schemas tab, select the schemas that you need to work with.

  10. Click OK to create the data source.

  11. Find your new data source in Database Explorer.

    • To write and run queries, open the default query console by clicking the data source and pressing F4.

    • To view and edit data, use Data editor.

    • To learn how to work with database objects in DataGrip, see Database objects.

Integration with Heroku Postgres
Last modified: 21 June 2023