🔌Connecting Flowise to PostgreSQL (Internal & External) with Docker Compose
Flowise is a powerful no-code tool to build and run LLM flows. By default, it uses SQLite for storage, but for production or team-based use, PostgreSQL is a more robust option.
In this post, you’ll learn how to connect Flowise to both internal and external PostgreSQL databases using Docker Compose — and how to verify that the database is actually being populated.
🔸 Option 1: Using an Internal PostgreSQL Container
This is perfect for local development or when you want everything containerized.
✅ Docker Compose Setup
version: "3.9"
services:
flowise:
image: flowiseai/flowise:latest
container_name: flowiseai
ports:
- "5023:5023"
volumes:
- ./flowiseai:/root/.flowise
environment:
PORT: 5023
FLOWISE_USERNAME: admin
FLOWISE_PASSWORD: changeme
DATABASE_TYPE: postgres
DATABASE_HOST: flowise-db
DATABASE_PORT: 5432
DATABASE_NAME: flowisedb
DATABASE_USER: flowiseuser
DATABASE_PASSWORD: flowisepass
depends_on:
flowise-db:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:5023"]
interval: 10s
timeout: 5s
retries: 5
entrypoint: /bin/sh -c "sleep 3; flowise start"
flowise-db:
image: postgres:15
environment:
POSTGRES_DB: flowisedb
POSTGRES_USER: flowiseuser
POSTGRES_PASSWORD: flowisepass
volumes:
- flowise-db-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U flowiseuser"]
interval: 10s
timeout: 5s
retries: 5
volumes:
flowise-db-data:
Code language: JavaScript (javascript)
🔸 Option 2: Connecting to an External PostgreSQL Server
For production environments or when using a managed PostgreSQL host, you’ll want to connect Flowise to an external database.
✅ .env
File Example
PORT=5023
FLOWISE_USERNAME=userName
FLOWISE_PASSWORD=userPassword
POSTGRES_DB=flowisedb
POSTGRES_USER=postgres
POSTGRES_PASSWORD=dbPassword
💡 Make sure this
.env
file is in the same directory as yourdocker-compose.yml
and not committed to version control.
✅ docker-compose.yml
(for external DB)
version: "3.9"
services:
flowise:
image: flowiseai/flowise:latest
container_name: flowiseai
ports:
- "5023:${PORT}"
volumes:
- ./flowiseai:/root/.flowise
environment:
PORT: ${PORT}
FLOWISE_USERNAME: ${FLOWISE_USERNAME}
FLOWISE_PASSWORD: ${FLOWISE_PASSWORD}
DATABASE_TYPE: postgres
DATABASE_HOST: 192.168.1.215
DATABASE_PORT: 5432
DATABASE_NAME: ${POSTGRES_DB}
DATABASE_USER: ${POSTGRES_USER}
DATABASE_PASSWORD: ${POSTGRES_PASSWORD}
restart: on-failure:5
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:5023"]
interval: 10s
timeout: 5s
retries: 5
entrypoint: /bin/sh -c "sleep 3; flowise start"
Code language: JavaScript (javascript)
✅ No need to define
flowise-db
service here, since the DB is external.
🔐 PostgreSQL Server Checklist (External DB)
🛠️ Make Sure to:
Before starting the Flowise container, make sure the external PostgreSQL server is correctly set up.
✅ Create the database
sudo -u postgres psql -c "CREATE DATABASE flowisedb;"
✅ (Optional) Create a dedicated user
CREATE USER flowiseuser WITH ENCRYPTED PASSWORD 'flowisepass';
GRANT ALL PRIVILEGES ON DATABASE flowisedb TO flowiseuser;
🔐 This allows Flowise to use a dedicated DB user instead of the default
postgres
superuser.
- Allow remote access
Inpg_hba.conf
:
host flowisedb postgres 192.168.1.0/24 md5
In postgresql.conf
:
listen_addresses = '*'
Code language: JavaScript (javascript)
Restart PostgreSQL:
sudo systemctl restart postgresql
- Open port 5432 in your firewall
🧪 How to Check If Flowise Populated the Database
- Login to the database:
sudo -u postgres psql -d flowisedb
- List tables:
\dt
You should see tables like:
public | flows
public | users
public | agents
Code language: PHP (php)
- Check for data:
SELECT COUNT(*) FROM flows;
✅ Conclusion
Whether you’re deploying Flowise in a containerized dev setup or connecting to an external production-grade database, PostgreSQL is a reliable and scalable option.
- Use internal PostgreSQL for quick setup and testing.
- Use external PostgreSQL for high-availability, shared deployments.
Don’t forget to secure your database and confirm that Flowise is actually writing to it.
💬 Need help connecting Flowise to your custom DB setup? Drop a comment below or reach out!
Let me know if you’d like this exported in HTML for direct WordPress posting or if you want to include screenshots or a video walkthrough too!