PostgreSQL Database
Overview
CompactHive provides a managed PostgreSQL database via the CloudNativePG (CNPG) operator. Each tenant that enables the Database service gets an isolated PostgreSQL instance running in its own namespace.
Connection details
Go to portal → Connect. Under "PostgreSQL" you'll find:
| Field | Value |
|---|---|
| Host | pg-<tenant-id>-rw.<namespace>.svc.cluster.local |
| Port | 5432 |
| Database | Your tenant slug |
| Username | Same as the database name |
| Password | Click to reveal on the Connect page |
Note: the database and username are set to your tenant slug during provisioning, not a generic name like "app". Check the Connect page or the portal's Developer Guide for your exact values.
Connection string
postgresql://SLUG:PASSWORD@pg-<tenant-id>-rw.<namespace>.svc.cluster.local:5432/SLUG
Use this as your DATABASE_URL environment variable when deploying apps. The exact pre-filled connection string is on the portal → Developer Guide page.
From your app
Since your app runs in the same Kubernetes namespace, it reaches PostgreSQL via the internal service DNS name — no VPN or external access is needed.
// Node.js (pg)
const { Pool } = require('pg');
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
# Python (psycopg2)
import psycopg2
conn = psycopg2.connect(os.environ['DATABASE_URL'])
// Go (pgx)
conn, err := pgx.Connect(ctx, os.Getenv("DATABASE_URL"))
Version
PostgreSQL 17 (the latest CNPG-supported version at time of writing).
Backups
CNPG runs a daily base backup plus continuous WAL archiving to the platform's backup object store automatically — no setup needed on your side. If you need a one-off export, run pg_dump from within your namespace.
Limitations
- Single instance (no HA read replicas) on every tier today.
- Storage is limited by your database's own storage allocation, billed separately per Gi — see the pricing page.
- No external access by default — connect from within your namespace only, or over the Headscale VPN add-on (Business tier and up).
- Superuser access is not provided — your role has full DDL/DML on your own database.
No comments to display
No comments to display