# Setup fails: Cannot allocate memory

**URL:** https://meta.discourse.org/t/setup-fails-cannot-allocate-memory/235149
**Category:** Self-hosting
**Created:** [August 4, 2022, 7:10pm UTC](https://meta.discourse.org/t/setup-fails-cannot-allocate-memory/235149 "2022-08-04T19:10:22Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![rsx](https://avatars.discourse-cdn.com/v4/letter/r/ce73a5/32.png) [@rsx](https://meta.discourse.org/u/rsx)
#### Post date: [August 4, 2022, 7:10pm UTC](https://meta.discourse.org/t/setup-fails-cannot-allocate-memory/235149/1 "2022-08-04T19:10:23Z")

</div>

Hi,

I’m new to discourse and tried to install it the very fist time. The first try even did not create the database and second after (deleting everything and starting from scratch) is again complaining:

```plaintext
2022-08-04 18:51:53.698 UTC [41] FATAL: could not map anonymous shared memory: Cannot allocate memory
2022-08-04 18:51:53.698 UTC [41] HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory, swap space, or huge pages. To reduce the request size (currently 1125310464 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections.

```

There is another error before (don’t know if relevant):

```plaintext
I, [2022-08-04T18:51:52.606862 #1] INFO -- : > socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1
2022/08/04 18:51:52 socat[18] E connect(6, AF=1 "/shared/postgres_run/.s.PGSQL.5432", 36): No such file or directory

```

The machine is a virtual server (don’t know which technology) with 4 GB RAM and 138 GB free space.

Could find any suitable hint here. Hence, any idea how to fix?

TIA  
Roland

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [August 4, 2022, 7:13pm UTC](https://meta.discourse.org/t/setup-fails-cannot-allocate-memory/235149/2 "2022-08-04T19:13:00Z")

</div>

Is this the only thing running within the VM?

What’s the result of `cat /proc/meminfo | grep MemFree` ?

Did you follow the [Standard Install](https://meta.discourse.org/t/142537?silent=true) and run `discourse-setup`? It should tune the memory settings for the spec of the VM assuming it meets the minimum requirements.

What are `db_shared_buffers`, `unicorn_workers` and `db_work_mem` in your app.yml?

---

<div class="post-metadata">

### Author: ![rsx](https://avatars.discourse-cdn.com/v4/letter/r/ce73a5/32.png) [@rsx](https://meta.discourse.org/u/rsx)
#### Post date: [August 4, 2022, 7:22pm UTC](https://meta.discourse.org/t/setup-fails-cannot-allocate-memory/235149/3 "2022-08-04T19:22:11Z")

</div>

> [@](#):
>
> Is this the only thing running within the VM?

Yes (except one small perl script).

> [@](#):
>
> What’s the result of `cat /proc/meminfo | grep MemFree` ?

MemFree: 758840 kB

But more than 3 GB is for cache.

> [@](#):
>
> Did you follow the [Standard Install](https://meta.discourse.org/t/142537) and run `discourse-setup`?

The latter without any changes.

> [@](#):
>
> What are `db_shared_buffers`, `unicorn_workers` and `db_work_mem` in your app.yml?

```plaintext
db_shared_buffers: "1024MB"
no entry for unicorn_workers
#db_work_mem: "40MB"

```

---

<div class="post-metadata">

### Author: ![rsx](https://avatars.discourse-cdn.com/v4/letter/r/ce73a5/32.png) [@rsx](https://meta.discourse.org/u/rsx)
#### Post date: [August 4, 2022, 7:28pm UTC](https://meta.discourse.org/t/setup-fails-cannot-allocate-memory/235149/4 "2022-08-04T19:28:26Z")

</div>

If have changed `db_shared_buffers` to 512 MB and have rebuild the app:

> ./launcher rebuild app

That looks much better now.
