Dotnet API - Connecting to Postgres DB

I’m not entirely sure how I am supposed to setup my fly.toml file so that my application can communicate with the postgres db.

Here is my fly.toml file

Here is where I’m trying to define the connection

Can someone point me in the right direction? I would think that I need to define another “service” within the fly.toml file but it wasn’t entirely clear to me as to how to define that.

I’m able to do the local proxy with the db and use DBeaver to connect to the postgres db, so I know that the postgres db hosted by fly is online and working.


Hi there,

You don’t need to add a new service to your first app fly.toml. It seems you already have Postgres up and running, so I think Attach or Detach a Fly App · Fly Docs is what you are looking for.

Yup! I did that, was able to attach successfully - so the secret DATABASE_URL got created.

Am I doing something wrong here with trying to access that secret?

This can be closed. The issue was that the connection string provided when creating the db had the host as connect-api-db.flycast. The correct host is connect-api-db.internal

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.