Lost postgres Password

Hi,

I have lost my database credentials. Is there a way to retrieve or reset the password ?

Thanks for your help

If you fly postgres attach, it will add a DATABASE_URL to your server that you can use to retrieve the password

➜  shopify git:(main) ✗ fly postgres attach --help
Attach a postgres cluster to an app

Usage:
  flyctl postgres attach [flags]

Flags:
  -a, --app string             App name to operate on
  -c, --config string          Path to an app config file or directory containing one (default "./fly.toml")
      --database-name string   database to use, defaults to a new database with the same name as the app
      --database-user string   the database user to create, defaults to creating a user with the same name as the consuming app
  -h, --help                   help for attach
      --postgres-app string    the postgres cluster to attach to the app
      --variable-name string   the env variable name that will be added to the app. Defaults to DATABASE_URL

Global Flags:
  -t, --access-token string   Fly API Access Token
  -j, --json                  json output
      --verbose               verbose output

Hello @Claudio! If you have an app deployed, you can fly ssh console and then run

echo $DATABASE_URL

And it will print it out. It is this ENV variable that is set when you attach a DB.

Hope that helps!

2 Likes