Can't establish connection to postgres database

I have followed the documentation for creating a postgres database cluster and attaching it to an existing fly app. Unfortunately I’m not able to establish a connection inside the fly app when deploying.

The App is a next.js application with prisma, by building the project I am also running a migration for the database. But the build fails because of failed connection.

#15 48.45 Error: P1001: Can't reach database server at `top2.nearest....`:`5432`

I have also set private_network = true in my fly.toml but with no success.

One thing to check before further debugging: is that postgres cluster within the same organization as your app? If one is in “personal”, and the other in “something-else”, the connection will fail. I made that mistake with one of mine once :slight_smile:

1 Like

Thank you for the hint! Just checked they’re both in “personal”

No problem. It’s not that then.

Next would be checking the database app is ok, running, etc. Try checking its status (scroll down a bit to see further status check commands e.g fly checks list -a name-pg-app), and see if there are any errors shown:

If not, not sure what else to suggest.

Database is running ok, all status looks good. Also have been able establishing a connection locally via WireGuard but still no success inside the fly app.