R
Railway6mo ago
jins

How to add pgBouncer to existing Postgres database

Are there any guide on adding pgBouncer to an existing Postgres DB on Railway? I saw this template but I'm sure this deploys a brand new DB? https://railway.app/template/OpUzwe
Solution:
that service may use the postgres icon, but it does not come with a database, that is just the bouncer service. if your current postgres database is named Postgres then you will not need any config to hook the bouncer service up to your existing database when you deploy the template into your project...
Jump to solution
15 Replies
Percy
Percy6mo ago
Project ID: c0958e3e-4cd8-4f89-9376-7c4003820f57
jins
jinsOP6mo ago
c0958e3e-4cd8-4f89-9376-7c4003820f57
Solution
Brody
Brody6mo ago
that service may use the postgres icon, but it does not come with a database, that is just the bouncer service. if your current postgres database is named Postgres then you will not need any config to hook the bouncer service up to your existing database when you deploy the template into your project
jins
jinsOP6mo ago
Would I then use the same connection string and append ?pgbouncer=true ? It looks like this deploys pgBouncer to a new project. Is this correct or should it be deployed to the project I need it for?
Brody
Brody6mo ago
the pgbuncer service comes with a connection string and you should reference that instead yes deploying from the template page would deploy it into a new project, if you open your existing project first then click create and choose the template it will deploy into the same project
jins
jinsOP6mo ago
ok got it thanks!
Brody
Brody6mo ago
no problem!
jins
jinsOP6mo ago
It provisioned the template in my project but these variables are empty strings so it crashes:
PGBOUNCER_DATABASE
POSTGRESQL_DATABASE
POSTGRESQL_HOST
POSTGRESQL_PASSWORD
POSTGRESQL_USERNAME
PGBOUNCER_DATABASE
POSTGRESQL_DATABASE
POSTGRESQL_HOST
POSTGRESQL_PASSWORD
POSTGRESQL_USERNAME
I assume I take the POSTGRESQL variables from my database but then what do I use for PGBOUNCER_DATABASE?
Brody
Brody6mo ago
you should not be setting any of these variables manually, please send a screenshot of your project
jins
jinsOP6mo ago
I noticed my DB name is not Postgres
Brody
Brody6mo ago
open pgboucers raw editor and change the namespace from Postgres to whatever the name of your postgres database is
jins
jinsOP6mo ago
SHould I rename the db and redeploy?
Brody
Brody6mo ago
no need, please try my suggestion
jins
jinsOP6mo ago
Success! Thank you
Brody
Brody6mo ago
no problem!
Want results from more Discord servers?
Add your server