Skip to main content
This page is archived. Fly Postgres (unmanaged) is no longer maintained, and Fly.io Support is not able to provide support or guidance for it. We now offer Fly.io Managed Postgres, our fully-managed database service that handles all aspects of running production PostgreSQL databases.These pages are kept for reference and are not listed in the navigation. The full set is indexed on the Fly Postgres (Unmanaged) page.
This guide runs you through how to migrate a database off of Heroku and onto Fly.io, but before that, let’s go over some major differences between Heroku’s managed Postgres offering and Fly.io’s Postgres offering. First and foremost, if you deploy your Postgres database to Fly.io you’ll be responsible for monitoring, configuring, scaling, and tuning it. If you don’t provision enough disk space, your database will run out of space and stop accepting write queries. If you don’t put monitoring in place for your database, a customer might alert you to an issue. Fly.io ships a set of tools that makes it easier to setup Postgres database instances, connect to their console, perform Postgres version upgrades, and create and restore snapshots of the volume where Postgres data is stored. The good news is that if you’re not comfortable managing your own Postgres database, you can still deploy a Fly app that connects to your managed Heroku Postgres database.

Provision and deploy a Postgres app to Fly

Let’s create a Postgres database on Fly.io. First we run a command to provision a database.
Now we have a Fly application called myapp-db that’s running. It’s important to understand that this is “just another Fly app” since we’ll be passing myapp-db into flyctl for the remainder of this documentation.

Importing your Database

Any new data created by your Heroku app during this database migration won’t be moved over to Fly.io. Consider taking your Heroku application offline or place in read-only mode if you want to be confident that this migration will move over 100% of your Heroku data to Fly.io.

Confirm your data has been imported correctly

Then connect to your database instance and run a few queries to see if its there.

Connect it to your application

Read through the documentation on connecting to your Postgres instances to start accessing your data.