Deploy PostgreSQL
Deploy PostgreSQL database with Senate
Deploy PostgreSQL
Deploy a production-ready PostgreSQL database with persistent storage.
Quick Setup
Time: ~3 minutes
1. Create Service
- Go to Services → Add Service
- Select your machine
- Name your service (e.g.,
postgres) - Click Create

2. Configure Source
- Go to the Source tab
- Select Docker Image as source type
- Enter image:
postgres:16-alpine - Click Save
3. Set Environment Variables
Go to the Environment tab and add:
POSTGRES_USER=myapp
POSTGRES_PASSWORD=your-secure-password
POSTGRES_DB=myapp_productionUse a strong password. This will be required to connect to your database.
4. Add Persistent Storage
- Go to the Storage tab
- Click Add Volume
- Configure:
- Volume Name:
postgres-data - Container Path:
/var/lib/postgresql/data
- Volume Name:

5. Expose Port
- Go to the Ports tab
- Click Add Port
- Configure:
- Protocol:
tcp - Published:
5432 - Target:
5432
- Protocol:
6. Deploy
Click Deploy to start PostgreSQL.
Connecting
Connection String
postgresql://myapp:your-secure-password@your-server-ip:5432/myapp_productionUsing psql
psql -h your-server-ip -U myapp -d myapp_productionFrom Application
// Node.js example
const { Pool } = require('pg');
const pool = new Pool({
connectionString: 'postgresql://myapp:your-secure-password@your-server-ip:5432/myapp_production'
});Backup & Restore
Create Backup
pg_dump -h your-server-ip -U myapp myapp_production > backup.sqlRestore Backup
psql -h your-server-ip -U myapp myapp_production < backup.sqlSecurity
Exposing PostgreSQL to the internet is risky. Consider these alternatives for production:
Recommended approaches:
- Internal only - Don't expose the port; access via SSH tunnel
- Firewall rules - Restrict to specific IP addresses
- VPN - Access only through private network
SSH Tunnel (Recommended)
ssh -L 5432:localhost:5432 user@your-server-ip
# Then connect to localhost:5432