# הפעלת Discourse עם pg\_bouncer ובסיס נתונים נפרד

**URL:** https://meta.discourse.org/t/running-discourse-with-pg-bouncer-and-a-separate-db/164505
**Category:** Self-hosting
**Created:** [18 בספטמבר,‏ 2020,‏ 9:22pm 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:** 3
**Page:** 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 בספטמבר,‏ 2020,‏ 9:22pm 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.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [20 בספטמבר,‏ 2020,‏ 4:15am UTC](https://meta.discourse.org/t/running-discourse-with-pg-bouncer-and-a-separate-db/164505/2 "2020-09-20T04:15:03Z")

</div>

I believe that you’ll need to use an ip that the container can access. It has its own local host, I believe

---

<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: [20 בספטמבר,‏ 2020,‏ 1:38pm UTC](https://meta.discourse.org/t/running-discourse-with-pg-bouncer-and-a-separate-db/164505/3 "2020-09-20T13:38:33Z")

</div>

Oh duh! Using my 10.x.x.x address it works just fine.

Now, this might not be the best solution, so if there’s any preferred way to access the host from the Discourse docker container I’m all ears.

Thanks!
