
Attach a Fly App
fly postgres attach is a convenience command to quickly associate a Fly App with your Fly Postgres cluster app.
- A new database and user are created in the Postgres cluster app, using the name of the consuming app (a Fly App). If the consuming app is named “my-app”, then both the database and the user are named “my_app”.
- The user is allocated a generated password.
- The consuming app and the Postgres app are marked as attached in the great floating ledger in the Fly.io cloud, which enables you to use
fly postgres detachlater.
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 tofly postgres attach, then you can revoke that access using fly postgres detach.
<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
Runfly 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.