a year ago
I'm just coming back around to updating an old project sicne the DB migrations a few months back.
I have PgBouncer connected to my Postgres DB.
From my app I am connecting to the Public DB URL for PgBouncer
then PgBouncer connects to the Postgres DB via private internal connection (whatever was setup during that deployment).
I just need to confirm that the app connecting to the public DB url is correct.
Thanks
0 Replies
a year ago
pgbouncer should be connecting to your database via the private network and your app should be connecting to pgbouncer via the private network too
okay this is working:
DATABASE_URL=${{PgBouncer.DATABASE_PRIVATE_URL}}?pgbouncer=true
DATABASE_URL_DIRECT=${{myapp-db.DATABASE_URL}}
I'm using prisma and their pgbouncer docs say to set the pgBouncer URL then connect direct to postgres as directUrl
for Prisma Migrate
If I try to use the private Url for postgres for Direct I get an error but I think it should be fine connecting to public?
Datasource "db": PostgreSQL database "railway", schema "public" at "dbname.railway.internal:5432"
Error: P1001: Can't reach database server at `dbname.railway.internal:5432`
Please make sure your database server is running at `dbname.railway.internal:5432`.
a year ago
you do not want to connect to the public url as that would subject yourself to egress fees
a year ago
are you getting that error during build?
If I change this to DATABASE_URL_DIRECT=${{myapp-db.DATABASE_PRIVATE_URL}}
in the variables and deploy I get that error in the build log and it fails
But it works with DATABASE_URL_DIRECT=${{myapp-db.DATABASE_URL}}
a year ago
the private network is not available during build on the legacy builder, switch to the new builder in the service settings
a year ago
no problem!