Deployment
Creating Fly Postgres
Choose managed or unmanaged Fly Postgres and configure application connectivity.
When to use this page
- You need a PostgreSQL database for your Fly-hosted application.
- You are deciding between managed and unmanaged Fly Postgres options.
Prerequisites
- Fly app already created.
- Fly organization and region selected.
- Decision whether production requires managed operations.
Fly.io offers two PostgreSQL options.
Option comparison
| Option | Best for | Tradeoff |
|---|---|---|
| Unmanaged Postgres | Development/staging, lower-cost setups | You own backups, maintenance, and upgrade operations |
| Managed Postgres (MPG) | Production workloads requiring reliability | Higher cost, less low-level control |
Unmanaged Postgres
Self-managed PostgreSQL clusters that you deploy and maintain yourself.
Documentation: https://fly.io/docs/postgres/getting-started/create-pg-cluster/

Recommended for: development and staging environments
Key points:
- Full control over configuration
- You manage backups and maintenance
- Lower cost but requires more hands-on management
Managed Postgres (MPG)
Fully managed PostgreSQL service handled by Fly.io.
Documentation: https://fly.io/docs/mpg/create-and-connect/

Recommended for: production environments
Key points:
- Automated backups and maintenance
- High availability options
- Managed updates and security patches
Setup checklist
- Make sure to make them in correct organization and region
- Decide the initial size and node count
- Confirm whether you need high availability or a single node
After creation
- You'll receive a
POSTGRES_URLconnection string - Add it to your app's secrets:
fly secrets set POSTGRES_URL=<your-postgres-url>
Verify
- Database is reachable from your Fly app.
POSTGRES_URLis set and application connects successfully.- Backup settings match your environment requirements.
Backups and maintenance
- Confirm automated backups are enabled (managed by default, manual for unmanaged)
- Decide on retention and restore testing cadence
Troubleshooting
- Connection timeout from app: Verify network access and connection URL credentials.
- Migration failures: Check database user privileges and migration logs.
- Unexpected downtime on unmanaged setup: Confirm backup/restore runbook exists and is tested.