Scale to zero for Postgres Development projects

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.

fly config save --app <app-name>

Open the fly.toml file and remove the following line from the [env] section:

  FLY_SCALE_TO_ZERO = "1h"

Verify what image you’re running:

fly image show --app <app-name>

Finally, deploy your changes. For example:

fly deploy . --image flyio/postgres-flex:15.2