rembrembdocs

Attach a Fly App

fly postgres attach is a convenience command to quickly associate a Fly App with your Fly Postgres cluster app.

fly postgres attach <postgres app name> --app <app name>

When you attach an app to Postgres, a number of things happen:

When the now-attached consuming app starts, it will have access to an environment variable DATABASE_URL set to a Postgres connection URI with the username, password, host, port, and dbname filled in.

Detach a Fly App

If the consuming app’s access to this database was purely due to fly postgres attach, then you can revoke that access using fly postgres detach.

fly postgres detach <postgres app name> --app <app name>

This will remove the <app name> user from the Postgres cluster, and the DATABASE_URL secret from the <app name> app. The platform will no longer view the two apps as associated. The database is not removed.

Check if a Fly App is attached to a Postgres app

Run fly postgres users list --app <postgres app name> on your Postgres cluster app. If there is an attached Fly App, then the app’s name will be in the list of users. See Users & Roles.