Forum Discussion

KalpeshClearDu's avatar
KalpeshClearDu
Regular Visitor
1 year ago
Solved

Power BI DirectQuery to AWS RDS PostgreSQL via SSH Tunnel – SSL Certificate Validation Error

Hi all, I’m working on a project where I need to connect Power BI (DirectQuery mode) to an AWS RDS (PostgreSQL) instance. The RDS is hosted in a private VPC and is only accessible through a VPN and ...
  • johnbasha33's avatar
    1 year ago

    KalpeshClearDu 

    This is a known and painfully tricky issue when trying to use DirectQuery over an SSH tunnel with SSL-enabled PostgreSQL (especially via AWS RDS). You’ve done almost everything right, and it’s clear this isn’t just a standard connectivity problem — it’s certificate validation inside Power BI’s DirectQuery engine, which behaves differently from Import or tools like pgAdmin.

    Option 1: Use Server Compatibility Mode in connection string

    Power BI allows advanced parameters — try tweaking the SSL behavior directly:

    1. When connecting in Power BI, choose DirectQuery, then select Advanced options.

    In Additional settings, add:

    Trust Server Certificate=true;
    Ssl Mode=Require;

    Option 2: Modify the hosts file + use actual RDS endpoint

    You can trick Power BI into thinking it's talking to the RDS endpoint:

    1. Open your local hosts file (as admin):
      C:\Windows\System32\drivers\etc\hosts

    Add a line like:
    127.0.0.1 your-rds-endpoint.rds.amazonaws.com
    Then connect in Power BI using:
    your-rds-endpoint.rds.amazonaws.com

    This matches the SSL certificate’s hostname, even though the SSH tunnel is to localhost.

    ⚠️ Be sure that your tunnel is forwarding to localhost:5432 in this case.

    Option 3: Use a Power BI Gateway (for scheduled refresh, not desktop)

    If your end goal is Power BI Service (not just Desktop), you'd typically need to:

    • Configure the On-premises data gateway to use ODBC + Import (DirectQuery to private RDS is not fully supported out-of-the-box via SSH tunnels)

    • Or host a custom service on EC2/VPN that routes securely

    But since you're focused on Desktop testing, this doesn’t help you immediately.


    Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!