I am having issues connecting to a Postgres application through a Dockerfile on deploy. The database is available when connecting from directly from the application itself (i.e fly ssh console).
P1001: Can't reach database server at `postgres.internal`:`5432`
Please make sure your database server is running at `postgres.internal`:`5432`.
Any help on the matter would be greatly appreciated.
What is the name of your database application? It’s probably not postgres. If you app name is my-postgres-cluster then your DATABASE_URL should also contain it, like:
One thing: setting the DATABASE_URL in the Dockerfile is insecure as it will show up when inspecting images.
Instead, you can run yarn prisma migrate as a release command instead of requiring your build to access the database. Release commands run after build, but before deployment, and they inherit the app environment/secrets. Builds do not.