# Discourse draaien met pg\_bouncer en een aparte DB

**URL:** <https://meta.discourse.org/t/running-discourse-with-pg-bouncer-and-a-separate-db/164505>\
**Category:** Self-hosting\
**Created:** [18 september 2020 om 21:22 UTC](https://meta.discourse.org/t/running-discourse-with-pg-bouncer-and-a-separate-db/164505 "2020-09-18T21:22:28Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![bsawicki](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@bsawicki](https://meta.discourse.org/u/bsawicki)\
**Post date:** [18 september 2020 om 21:22 UTC](https://meta.discourse.org/t/running-discourse-with-pg-bouncer-and-a-separate-db/164505/1 "2020-09-18T21:22:28Z")

</div>

I’m trying to set up our Discourse instance to connect to a separate Postgres DB hosted on Azure (set up as described [here](https://meta.discourse.org/t/running-discourse-with-a-separate-postgresql-server/46375)) via pg\_bouncer and I’m having issues.

Our discourse is hosted on a VM in Azure. I have pg\_bouncer installed on it and configured, and I am able to verify that I can connect to the hosted DB from the VM via:

`psql -h 127.0.0.1 -p 5432 -U [username] -d [database]`

In my app.yml, I changed from using the DB hostname to using 127.0.0.1:

`DISCOURSE_DB_HOST: [was hostname, tried 127.0.0.1]`

When rebuilding the app I get the following error:

```plaintext
I, [2020-09-18T20:48:51.653890 #1] INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'
rake aborted!
PG::ConnectionBad: could not connect to server: Connection refused
	Is the server running on host "127.0.0.1" and accepting
	TCP/IP connections on port 5432?

```

The only thing that I can think of that’s different between how I’m connecting via psql and the setup of my app.yml is that there’s a password specified in app.yml that isn’t necessary in psql because it’s set up in the pg\_bouncer userlist.

Any help would be appreciated.

---

_[View the full topic](https://meta.discourse.org/t/running-discourse-with-pg-bouncer-and-a-separate-db/164505)._
