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

OptionBest forTradeoff
Unmanaged PostgresDevelopment/staging, lower-cost setupsYou own backups, maintenance, and upgrade operations
Managed Postgres (MPG)Production workloads requiring reliabilityHigher 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/

Unmanaged Postgres

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/

Managed Postgres

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_URL connection 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_URL is 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.

On this page