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.
The scale to zero feature is only available for new Postgres clusters that use the Development configuration. The one hour timeout is not configurable.
If you select the Development configuration when you create your Fly Postgres app, then you also get the option to have your database scale down to zero after one hour. After one hour, if there are no open connections, then the database shuts down and waits to restart until something tries to connect again. If there are open connections, then the database stays running and checks for open connections again in 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. You can learn more about making apps exit when idle.

Turn off the scale to zero feature

The scale to zero feature is controlled by the FLY_SCALE_TO_ZERO environment variable. To turn off scale to zero, you first need to get and save the fly.toml file locally, since the automated Postgres creation process doesn’t generate a fly.toml file in the working directory.
Open the fly.toml file and remove the following line from the [env] section:
Verify what image you’re running:
Finally, deploy your changes. For example: