Important: We are not able to provide support or guidance for unmanaged Postgres. We now offer Fly.io Managed Postgres , our fully-managed database service that handles all aspects of running production PostgreSQL databases.
To create a Postgres cluster, use the fly postgres create command. The command will walk you through the creation with prompts for name, region, and VM resources.
Because we keep adding shorter aliases, you can use any of the following and get the same result: flyctl postgres, fly postgres, flyctl pg, and fly pg.
During this process, you get to choose from several preset resource configurations for the app:
The “Production” options give you a three-node cluster in a leader-replica configuration. A single-node “Development” instance can readily be scaled and expanded to more regions.
If you select the “Development” single-node cluster configuration, then you can choose to scale down to zero if there are no open connections after one hour.
You might need to configure any apps that connect to your Postgres app to scale to zero as well, otherwise your Postgres database will never have zero connections and will never scale down. Your app might also need to be able to wait for the database to start back up. Learn more about the scale to zero feature, including how to turn it off.
After answering all the prompts, you’ll see a message saying that the cluster is being created. Take heed of the reminder to save your password in a safe place!
Once deployment is complete, you’ll be looking to connect an app to your new Postgres cluster. There’s a good chance you’ll want to attach a Fly app next.
Before going any further, a note: the automated Postgres creation process doesn’t generate a fly.toml file in the working directory. This means that when you use flyctl commands that would otherwise look for an app name in fly.toml, you’ll have to specify the app, like so: