Local Postgres Database
Overview
This guide shows you how to connect a locally running PostgreSQL database to Bemi AI. This is helpful for initial testing of the platform by connecting and replicating data from your PostgreSQL database, allowing you to build AI agents that investigate and resolve customer issues.
At a high level, you will:
- Use ngrok to securely expose your local PostgreSQL database (so Bemi AI can reach it without complex networking).
- Collect your database connection credentials (Host, Port, Database Name, Username, and Password).
- Enter these credentials in dashboard.bemi.ai.
- Select the tables you wish to sync.
Step 1: Install & Launch ngrok
-
Download & Install ngrok
- Visit ngrok.com/download and install it for your operating system.
-
Launch ngrok on the same port PostgreSQL uses (typically
5432):ngrok tcp 5432
ngrok will display a forwarding address in this format:
Forwarding tcp://0.tcp.ngrok.io:12345 -> localhost:5432
Host: 0.tcp.ngrok.io
Port: 12345
Keep ngrok running so your tunnel remains active.
Step 2: Gather Your Postgres Credentials
You’ll need the following to share with Bemi AI:
- Host: The ngrok forwarding host (e.g., 0.tcp.ngrok.io).
- Port: The ngrok forwarded port (e.g., 12345).
- Database Name: Usually postgres or your custom database.
- Username: Could be postgres (or another Postgres user).
- Password: The password for that user.
Step 3: Update pg_hba.conf (Allow External Connections)
Locate and open your pg_hba.conf. Common locations:
- Ubuntu/Debian:
/etc/postgresql/<version>/main/pg_hba.conf - macOS/Homebrew:
/usr/local/var/postgres/pg_hba.conf - Windows:
C:\Program Files\PostgreSQL\<version>\data\pg_hba.conf
Add or modify a line to permit password-based connections. For example:
host all all all md5
This instructs PostgreSQL to allow all users (all) from any IP address (all) to authenticate using a password (md5).
Restart or reload PostgreSQL for changes to take effect:
sudo service postgresql restart
Step 4: Connect at Bemi AI
On the Bemi AI Dashboard, enter the Host, Port, Database Name, Username, and Password from above.