# Error rebuilding on 2GB RAM without swap

**URL:** https://meta.discourse.org/t/error-rebuilding-on-2gb-ram-without-swap/280861
**Category:** Self-hosting
**Tags:** server-resources
**Created:** [October 3, 2023, 9:55am UTC](https://meta.discourse.org/t/error-rebuilding-on-2gb-ram-without-swap/280861 "2023-10-03T09:55:30Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![MarcP](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcp/32/160184_2.png) [@MarcP](https://meta.discourse.org/u/MarcP)
#### Post date: [October 3, 2023, 9:55am UTC](https://meta.discourse.org/t/error-rebuilding-on-2gb-ram-without-swap/280861/1 "2023-10-03T09:55:30Z")

</div>

> [@Error on launcher rebuild app](https://meta.discourse.org/t/error-on-launcher-rebuild-app/260689):
>
> I tried to rebuild discourse with /var/discourse/launcher rebuild app and this happens after a fail upgrade: FAILED -------------------- Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake themes:update assets:precompile' failed with return #\<Process::Status: pid 733 exit 137\> Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.1.1/lib/pups/exec\_command.rb:117:in `spawn' exec failed with the params {"cd"=\>"$home", "hook"=\>"assets\_precompile", "cmd"=\>["su di…

I am running into the exact same issue as the topic above, on a 2GB ram instance.

Right before the error, I made a htop snapshot - notice swap is not being used.

 ![image](https://global.discourse-cdn.com/meta/original/4X/c/4/e/c4e2d6425de556d338b1f7e92ff3e6f62be45a9a.jpeg)

---

<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: [October 3, 2023, 10:59am UTC](https://meta.discourse.org/t/error-rebuilding-on-2gb-ram-without-swap/280861/2 "2023-10-03T10:59:42Z")

</div>

You need 2gb swap. If you ran discourse-setup it would have created it

---

<div class="post-metadata">

### Author: ![MarcP](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcp/32/160184_2.png) [@MarcP](https://meta.discourse.org/u/MarcP)
#### Post date: [October 3, 2023, 11:00am UTC](https://meta.discourse.org/t/error-rebuilding-on-2gb-ram-without-swap/280861/3 "2023-10-03T11:00:59Z")

</div>

Should’ve stated that this is running for 4 years+, I rebuild every 2/3 months.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [October 3, 2023, 11:44am UTC](https://meta.discourse.org/t/error-rebuilding-on-2gb-ram-without-swap/280861/4 "2023-10-03T11:44:17Z")

</div>

Yep, swap is critical.

Things will fail without it.

---

<div class="post-metadata">

### Author: ![MarcP](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcp/32/160184_2.png) [@MarcP](https://meta.discourse.org/u/MarcP)
#### Post date: [October 3, 2023, 11:45am UTC](https://meta.discourse.org/t/error-rebuilding-on-2gb-ram-without-swap/280861/5 "2023-10-03T11:45:11Z")

</div>

So basically run discourse-setup again instead of a regular rebuild?

---

<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: [October 3, 2023, 3:27pm UTC](https://meta.discourse.org/t/error-rebuilding-on-2gb-ram-without-swap/280861/6 "2023-10-03T15:27:17Z")

</div>

If you ran `discourse-setup` to start then perhaps there is something about your system that kept it from creating swap. You might need to just create the swap yourself. Google something like “create swap YOUR-LINUX-DISTRIBUTION”

---

<div class="post-metadata">

### Author: ![MarcP](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcp/32/160184_2.png) [@MarcP](https://meta.discourse.org/u/MarcP)
#### Post date: [October 3, 2023, 3:47pm UTC](https://meta.discourse.org/t/error-rebuilding-on-2gb-ram-without-swap/280861/7 "2023-10-03T15:47:22Z")

</div>

Thanks Jay & Robert. Indeed the swap was missing.

Solution is:

```plaintext
cd /var/discourse
chmod 700 containers # might be redundant, but no harm
./discourse-setup

```

The setup will recreate the swap and exit.

```plaintext
WARNING: Discourse requires at least 2GB of swap when running with 2GB of RAM
or less. This system does not appear to have sufficient swap space.

Without sufficient swap space, your site may not work properly, and future
upgrades of Discourse may not complete successfully.

Ctrl+C to exit or wait 5 seconds to have a 2GB swapfile created.
Setting up swapspace version 1, size = 2 GiB (2147479552 bytes)
no label, UUID=e0321b22-.....
/swapfile swap swap auto 0 0
vm.swappiness = 10
The configuration file containers/app.yml already exists!

. . . reconfiguring . . .

Saving old file as app.yml.2023-10-03-153852.bak
Stopping existing container in 5 seconds or Control-C to cancel.

```

Then just do a regular rebuild.

---

<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: [October 3, 2023, 3:50pm UTC](https://meta.discourse.org/t/error-rebuilding-on-2gb-ram-without-swap/280861/8 "2023-10-03T15:50:00Z")

</div>

So you originally installed without running `discouse-setup`?

---

<div class="post-metadata">

### Author: ![MarcP](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcp/32/160184_2.png) [@MarcP](https://meta.discourse.org/u/MarcP)
#### Post date: [October 3, 2023, 3:52pm UTC](https://meta.discourse.org/t/error-rebuilding-on-2gb-ram-without-swap/280861/9 "2023-10-03T15:52:12Z")

</div>

No, I used `discourse-setup` a few years ago to install this instance. I am not sure why the swap is killed, I did install something else on the server a while ago, which is now uninstalled, it may have done something I’m not aware of. Maybe this app interacted with swap, not my field of expertise, but the instance is up and running again.

---

<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: [November 2, 2023, 3:52pm UTC](https://meta.discourse.org/t/error-rebuilding-on-2gb-ram-without-swap/280861/10 "2023-11-02T15:52:53Z")

</div>

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