# Postgres connection error on 'bundle exec rails c'

**URL:** https://meta.discourse.org/t/postgres-connection-error-on-bundle-exec-rails-c/222153
**Category:** Self-hosting
**Created:** [March 28, 2022, 12:24pm UTC](https://meta.discourse.org/t/postgres-connection-error-on-bundle-exec-rails-c/222153 "2022-03-28T12:24:00Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![helmi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/helmi/32/114772_2.png) [@helmi](https://meta.discourse.org/u/helmi)
#### Post date: [March 28, 2022, 12:24pm UTC](https://meta.discourse.org/t/postgres-connection-error-on-bundle-exec-rails-c/222153/1 "2022-03-28T12:24:00Z")

</div>

I’m trying to change some forum settings through the console. I didn’t do that a lot yet so I searched for similar questions on the forum.

Unfortunately when executing ‘bundle exec rails c’ i get an error trace that ends with this line

`/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/postgresql_adapter.rb:81:in `rescue in new_client': connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: Peer authentication failed for user "discourse" (ActiveRecord::NoDatabaseError)`

Any idea what’s going on there? Forum itself runs fine - just updated to the latest version the other day.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [March 28, 2022, 12:43pm UTC](https://meta.discourse.org/t/postgres-connection-error-on-bundle-exec-rails-c/222153/2 "2022-03-28T12:43:56Z")

</div>

I get to the rails console from the server by using:

```plaintext
cd /var/discourse
./launcher enter app
rails c

```

There’s an example of changing a site setting in this topic, [Enable setting to allow admins to permanently delete data](https://meta.discourse.org/t/enable-the-hidden-can-permanently-delete-site-setting/206678) (this one is a hidden one, but the method is the same)

---

<div class="post-metadata">

### Author: ![helmi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/helmi/32/114772_2.png) [@helmi](https://meta.discourse.org/u/helmi)
#### Post date: [March 28, 2022, 12:53pm UTC](https://meta.discourse.org/t/postgres-connection-error-on-bundle-exec-rails-c/222153/3 "2022-03-28T12:53:36Z")

</div>

Thanks, I guess I mixed up both - I was doing bundle exec from within the app.

Still struggling though. I’m looking to change the IP regex for the [prometheus exporter plugin](https://meta.discourse.org/t/prometheus-exporter-plugin-for-discourse/72666).

Not sure which syntax is good to use. I tried

`SiteSetting.prometheus_trusted_ip_allowlist_regex=1.2.3.4` with escaping backslashes and quotes around it but nothing worked. 1.2.3.4 being a placeholder of my real IP.

---

<div class="post-metadata">

### Author: ![helmi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/helmi/32/114772_2.png) [@helmi](https://meta.discourse.org/u/helmi)
#### Post date: [March 28, 2022, 1:15pm UTC](https://meta.discourse.org/t/postgres-connection-error-on-bundle-exec-rails-c/222153/4 "2022-03-28T13:15:02Z")

</div>

Actually I just noticed it’s probably not a syntax issue

```plaintext
SiteSetting.prometheus_trusted_ip_allowlist_regex="123.145.167.189"
NoMethodError: undefined method `prometheus_trusted_ip_allowlist_regex=' for #<Class:0x000055a8093e7dd8>

```

Maybe @sam can help with that. Or I’m really just making a mistake here. 🤔

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [March 28, 2022, 2:06pm UTC](https://meta.discourse.org/t/postgres-connection-error-on-bundle-exec-rails-c/222153/5 "2022-03-28T14:06:53Z")

</div>

You must set `DISCOURSE_PROMETHEUS_TRUSTED_IP_ALLOWLIST_REGEX` and a ENV variable on your app.yml file.

---

<div class="post-metadata">

### Author: ![helmi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/helmi/32/114772_2.png) [@helmi](https://meta.discourse.org/u/helmi)
#### Post date: [March 28, 2022, 2:14pm UTC](https://meta.discourse.org/t/postgres-connection-error-on-bundle-exec-rails-c/222153/6 "2022-03-28T14:14:14Z")

</div>

Correct me if I’m wrong but I thought I could set it on runtime first. So I need to set it on app.yml first to then be able to modify it on runtime?

The forum is quite busy so I was hoping to be able to set it on runtime first before setting it permanently in the ENV.

Any hints about the syntax? Can this just be

```plaintext
DISCOURSE_PROMETHEUS_TRUSTED_IP_ALLOWLIST_REGEX: 123.145.167.189

```

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [March 28, 2022, 2:24pm UTC](https://meta.discourse.org/t/postgres-connection-error-on-bundle-exec-rails-c/222153/7 "2022-03-28T14:24:08Z")

</div>

> [@helmi](#):
>
> I thought I could set it on runtime first. So I need to set it on app.yml first to then be able to modify it on runtime?

No runtime changes, only via the ENV.

> [@helmi](#):
>
> Any hints about the syntax

It’s a Ruby Regex object, see [https://rubular.com/](https://rubular.com/)

> [@helmi](#):
>
> Can this just be
> 
> ```plaintext
> DISCOURSE_PROMETHEUS_TRUSTED_IP_ALLOWLIST_REGEX: 123.145.167.189
> 
> ```

Yes, that works.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [September 21, 2022, 12:54am UTC](https://meta.discourse.org/t/postgres-connection-error-on-bundle-exec-rails-c/222153/8 "2022-09-21T00:54:01Z")

</div>


