Getting a 500 error when trying to attach postgres DB to my app

I have created a postgres db in fly, and deployed my app. When I try to attach one to the other I get an error:

❯ fly pg attach --postgres-app flagsmith-postgres
DEBUG Loaded flyctl config from/Users/ben/.fly/config.yml
DEBUG Loading app config from/Users/ben/projects/flagsmith/api/fly.toml
DEBUG Working Directory: /Users/ben/projects/flagsmith/api
DEBUG App Config File: /Users/ben/projects/flagsmith/api/fly.toml
DEBUG --> POST {{"query":"mutation($input: AttachPostgresClusterInput!) { attachPostgresCluster(input: $input) { app { name } postgresClusterApp { name } environmentVariableName connectionString environmentVariableName } }","variables":{"input":{"appId":"flagsmith","postgresClusterAppId":"flagsmith-postgres"}}}
Attaching...⣯ DEBUG <-- 500 (5.63s) {"errors":[{"message":"An unknown error occured.","extensions":{"code":"SERVER_ERROR"}}],"data":{}}
Error An unknown error occured.

For whatever reason the flagsmith database wasn’t returned when querying the list of databases so it tried to create it again, which failed. If you don’t mind could you try again?

Yep that’s working now.

1 Like