# Postgresql OOM Errors?

**URL:** https://meta.discourse.org/t/postgresql-oom-errors/354705
**Category:** Support
**Tags:** postgres
**Created:** [February 26, 2025, 9:33pm UTC](https://meta.discourse.org/t/postgresql-oom-errors/354705 "2025-02-26T21:33:42Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![piffy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/piffy/32/254198_2.png) [@piffy](https://meta.discourse.org/u/piffy)
#### Post date: [February 26, 2025, 9:33pm UTC](https://meta.discourse.org/t/postgresql-oom-errors/354705/1 "2025-02-26T21:33:42Z")

</div>

It seems that about every 30 minutes or so I am getting this error:

> ActiveRecord::ConnectionNotEstablished : connection to server on socket “/var/run/postgresql/.s.PGSQL.5432” failed: FATAL: the database system is in recovery mode

I have found it corresponds to dips in memory and the postgresql logs suggest an OOM error.

 ![image](https://global.discourse-cdn.com/meta/original/4X/9/3/d/93d113a99bdcae9b578ded7a18d43a601bd28dab.png)

> free -h

| | total | used | free | shared | buff/cache | available |
| --- | --- | --- | --- | --- | --- | --- |
| Mem: | 7.8Gi | 4.0Gi | 142Mi | 3.4Gi | 3.7Gi | 156Mi |
| Swap: | 2.0Gi | 1.4Gi | 659Mi | | | |

But I am having a difficult time trying to pinpoint where the memory is going.  
I have the following setup: ` 8 GB Memory / 4 AMD vCPUs / 160 GB Disk`

I did recently DOWNGRADE this from a beefier machine, which could be the issue. But I have updated my app.yml and rebuilt Discourse since then so I don’t know where the problem would be coming from.

app.yml:

> UNICORN\_WORKERS: 4  
> UNICORN\_SIDEKIQ\_MAX\_RSS: 1000

Any advice?

---

<div class="post-metadata">

### Author: ![piffy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/piffy/32/254198_2.png) [@piffy](https://meta.discourse.org/u/piffy)
#### Post date: [February 26, 2025, 9:35pm UTC](https://meta.discourse.org/t/postgresql-oom-errors/354705/2 "2025-02-26T21:35:18Z")

</div>

Annnnd while writing this I think I found the issue

I needed to adjust this in my app.yml from 4GB to 2GB

> db\_shared\_buffers: “2048MB”

I’ll check back in about 30 mins to see if it works. And I’ll keep the topic up in case others come across the same issue in the future.

Update: seems like it needs a full rebuild for the changes to take effect.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [March 28, 2025, 10:26pm UTC](https://meta.discourse.org/t/postgresql-oom-errors/354705/4 "2025-03-28T22:26:52Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
