Table of Contents

How to Connect PowerBi to Postgres Database

Below is a step-by-step documentation on how to export the port of PostgreSQL in Docker Compose, configure IP tables to create an external connection, and then connect Power BI to the Postgres Database:

Step 1 : Expose the Port of Postgres

db:
    image: postgres
    environment:
      POSTGRES_USER: my_user
      POSTGRES_PASSWORD: my_password
    ports:
      - "5432:5432"
$ docker-compose up -d

Step 2: Configure IP Tables

To create an external connection, you need to allow traffic to the PostgreSQL port in the IP tables of your VM. Follow these steps:

$ iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 7*** -j DNAT --to-destination <VM_IP>:5432

Note

Step 3: Connect Power BI to PostgreSQL

Now that you have exported the port and configured IP tables, you can connect Power BI to the PostgreSQL database:

 Server_IP:7***