I don't use Heroku but had a similar problem with AWS and had to configure the db provider and certificates as described below. I would think that something similar is needed for Heroku.
I did some digging and found 2 possible solutions for Heroku:
- Supply the additional settings
sslmode=Require;Trust Server Certificate=true
in the database connection. This does not seem to be an option with PowerBI, because even under "Advanced Settings" there is nowhere to provide these.
- Download the certificate for you database as described here and then follow much the same process as I did below to register the certificate with Windows. If Heroku supplies a P7B (PKCS#7 or pfx (PKCS#12) format certificate you can register that with Windows without having to do the conversion I described.
My setup of the Npgsql provider and AWS Certificates
PowerBI and Excel support connections to Postgres using the Npgsql .NET Data Provider. This provider is not installed by default on Windows. Here's how to install it:
- Download the appropriate .msi installer from the Npgsql releases page. The version you need depends on your version of Excel. I am running Office 365, which required version 4.0.x (I installed 4.0.10, download here).
- Run the installer. During the install there is an option to install to the GAC which is switched off by default - you must select to have the files installed to the GAC.
- Reboot your computer and you should be able to connect setup a Postgres connection in PowerBI or Excel.
AWS RDS Postgres - additional requirement
If you are connecting to a Postgres cluster running in AWS, when you attempt to connect to Postgres after installing the Npgsql provider you may get an error saying:
"The remote certificate is invalid according to the validation procedure"
Here's how to fix it:
- Download the public keys for AWS RDS regions: https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem
- Convert the bundle to a Windows certificate in P7B/PKCS#7 format. There are many ways to do this, and easy one is to use https://www.sslshopper.com/ssl-converter.html.
- In Windows, search for the "Manage User Certificates" utility and open it.
- Right-click on "Trusted Root Certificate Authorities", "All Tasks", "Import..."
- Select the .p7b file which was the output of converting the AWS keys to P7B format.
- Choose to place all certificates in the Trusted Root Certification Authorities store.
- You will probably have to confirm for each certificate - there is one per AWS region
You should now be able to connect to your AWS RDS Postgres database from PowerBI or Excel.