# Errno::ENOMEM: Cannot allocate memory

**URL:** https://meta.discourse.org/t/errno-cannot-allocate-memory/43736
**Category:** Self-hosting
**Tags:** server-resources
**Created:** [May 5, 2016, 2:32pm UTC](https://meta.discourse.org/t/errno-cannot-allocate-memory/43736 "2016-05-05T14:32:01Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![SkritterJosh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/skritterjosh/32/121854_2.png) [@SkritterJosh](https://meta.discourse.org/u/SkritterJosh)
#### Post date: [May 5, 2016, 2:32pm UTC](https://meta.discourse.org/t/errno-cannot-allocate-memory/43736/1 "2016-05-05T14:32:01Z")

</div>

I just ran an update and got the following error. Then when I refreshed the page to run it again it showed that the update had already been applied. Any thoughts?

```
Errno::ENOMEM: Cannot allocate memory - gzip -f -c -7 /var/www/discourse/public/assets/docker-manager-app-5abf141467f1e67d5d860236f75651be.js > /var/www/discourse/public/assets/docker-manager-app-5abf141467f1e67d5d860236f75651be.js.gz
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.6/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.6/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``'
/var/www/discourse/lib/tasks/assets.rake:108:in `gzip'
/var/www/discourse/lib/tasks/assets.rake:161:in `block (4 levels) in '
/var/www/discourse/lib/tasks/assets.rake:125:in `call'
/var/www/discourse/lib/tasks/assets.rake:125:in `block in concurrent?'
/var/www/discourse/lib/tasks/assets.rake:152:in `call'
/var/www/discourse/lib/tasks/assets.rake:152:in `block (3 levels) in '
/var/www/discourse/lib/tasks/assets.rake:141:in `each'
/var/www/discourse/lib/tasks/assets.rake:141:in `block (2 levels) in '
/var/www/discourse/lib/tasks/assets.rake:125:in `concurrent?'
/var/www/discourse/lib/tasks/assets.rake:137:in `block in '

```

---

<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: [May 5, 2016, 2:36pm UTC](https://meta.discourse.org/t/errno-cannot-allocate-memory/43736/2 "2016-05-05T14:36:06Z")

</div>

Do you have enough ram and swap?

```bash
free -m

```

---

<div class="post-metadata">

### Author: ![dylanh724](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dylanh724/32/119642_2.png) [@dylanh724](https://meta.discourse.org/u/dylanh724)
#### Post date: [May 5, 2016, 2:45pm UTC](https://meta.discourse.org/t/errno-cannot-allocate-memory/43736/3 "2016-05-05T14:45:00Z")

</div>

@SkritterJosh ME TOO!!

2gb droplet - way more than enough. I just saw the update and tried it.

 ![](https://global.discourse-cdn.com/meta/original/3X/a/8/a815ea9a2dce973c900162a24101901421de122f.png)

100% same err. Def have enough mem.

---

<div class="post-metadata">

### Author: ![SkritterJosh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/skritterjosh/32/121854_2.png) [@SkritterJosh](https://meta.discourse.org/u/SkritterJosh)
#### Post date: [May 5, 2016, 2:54pm UTC](https://meta.discourse.org/t/errno-cannot-allocate-memory/43736/4 "2016-05-05T14:54:30Z")

</div>

@Falco Yes, I do have enough ram and swap.

@dylanh724 I just updated docker and discourse using the terminal and it seemed to work, but using the discourse admin interface it didn’t.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 5, 2016, 8:45pm UTC](https://meta.discourse.org/t/errno-cannot-allocate-memory/43736/5 "2016-05-05T20:45:30Z")

</div>

Show us the output of `free -m`

---

<div class="post-metadata">

### Author: ![avorio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/avorio/32/120939_2.png) [@avorio](https://meta.discourse.org/u/avorio)
#### Post date: [May 5, 2016, 10:32pm UTC](https://meta.discourse.org/t/errno-cannot-allocate-memory/43736/6 "2016-05-05T22:32:43Z")

</div>

I got exactly the same error. Here’s the output:

```
Compressing: docker-manager-app-c32d676193f61b3085ec0e77f8d9fca361291a549828d82d1e33c356786f8ca0.js
gzip /var/www/discourse/public/assets/docker-manager-app-c32d676193f61b3085ec0e77f8d9fca361291a549828d82d1e33c356786f8ca0.js
Bundling assets
Compressing Javascript and Generating Source Maps
rake aborted!
Errno::ENOMEM: Cannot allocate memory - gzip -f -c -7 /var/www/discourse/public/assets/docker-manager-app-c32d676193f61b3085ec0e77f8d9fca361291a549828d82d1e33c356786f8ca0.js > /var/www/discourse/public/assets/docker-manager-app-c32d676193f61b3085ec0e77f8d9fca361291a549828d82d1e33c356786f8ca0.js.gz
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.6/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.6/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``'
/var/www/discourse/lib/tasks/assets.rake:108:in `gzip'
/var/www/discourse/lib/tasks/assets.rake:149:in `block (2 levels) in '
/var/www/discourse/lib/tasks/assets.rake:130:in `each'
/var/www/discourse/lib/tasks/assets.rake:130:in `block in '
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

```

And here’s `free -m`:

```
root@xyz:~# free -m
             total used free shared buffers cached
Mem: 2000 1586 414 36 63 276
-/+ buffers/cache: 1246 754
Swap: 0 0 0
root@xyz:~#

```

However, now `admin/upgrade` says that `docker_manager` is up to date:

`docker_manager (9b59950)`

---

<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: [May 5, 2016, 10:45pm UTC](https://meta.discourse.org/t/errno-cannot-allocate-memory/43736/7 "2016-05-05T22:45:16Z")

</div>

Set up a swap!

> [@Create a swapfile for your Linux server](https://meta.discourse.org/t/create-a-swapfile-for-your-linux-server/13880):
>
> bulb For servers with \<= 4GB of RAM, running ./discourse-setup will prompt for and automatically create a 2GB swapfile. Most cloud virtual machine providers do not set up swapfiles as part of their server provisioning. In particular, upgrading Discourse produces a lot of memory pressure. With a swap file, rather than randomly terminating processes with an out of memory error, things will slow down instead. Having a swap file is a cheap insurance policy that protects you from many other lo…

---

<div class="post-metadata">

### Author: ![avorio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/avorio/32/120939_2.png) [@avorio](https://meta.discourse.org/u/avorio)
#### Post date: [May 5, 2016, 10:50pm UTC](https://meta.discourse.org/t/errno-cannot-allocate-memory/43736/8 "2016-05-05T22:50:34Z")

</div>

Thanks. I just did that.

Is it safe to assume that the upgrade went well, then? Or how do I double-check?

---

<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: [May 5, 2016, 10:53pm UTC](https://meta.discourse.org/t/errno-cannot-allocate-memory/43736/9 "2016-05-05T22:53:37Z")

</div>

There is the version on /admin, and the version hash on the page source (CTRL+U) that you can check.

---

<div class="post-metadata">

### Author: ![SkritterJosh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/skritterjosh/32/121854_2.png) [@SkritterJosh](https://meta.discourse.org/u/SkritterJosh)
#### Post date: [May 6, 2016, 2:53am UTC](https://meta.discourse.org/t/errno-cannot-allocate-memory/43736/10 "2016-05-06T02:53:57Z")

</div>

@avorio I’m not sure if it’s safe to assume that. I also experienced the same thing where the upgrade failed, but then later it said everything was up to date. I went ahead and manually updated both docker and discourse. It did appear they still had updates perform and the dashboard was producing a false positive on the update.

---

<div class="post-metadata">

### Author: ![avorio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/avorio/32/120939_2.png) [@avorio](https://meta.discourse.org/u/avorio)
#### Post date: [May 6, 2016, 9:46pm UTC](https://meta.discourse.org/t/errno-cannot-allocate-memory/43736/11 "2016-05-06T21:46:07Z")

</div>

Hi @SkritterJosh! Thanks for that.

How do I manually update both docker and discourse, please?

---

<div class="post-metadata">

### Author: ![SkritterJosh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/skritterjosh/32/121854_2.png) [@SkritterJosh](https://meta.discourse.org/u/SkritterJosh)
#### Post date: [May 6, 2016, 10:27pm UTC](https://meta.discourse.org/t/errno-cannot-allocate-memory/43736/12 "2016-05-06T22:27:53Z")

</div>

On my particular setup using Ubuntu I ran the following commands to get things updated.

Docker:

> apt-get update  
> apt-get upgrade lxc-docker

Discourse

> cd /var/discourse  
> git pull  
> ./launcher rebuild app

---

<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: [May 6, 2016, 11:19pm UTC](https://meta.discourse.org/t/errno-cannot-allocate-memory/43736/13 "2016-05-06T23:19:28Z")

</div>

> [@SkritterJosh](#):
>
> apt-get upgrade lxc-docker

see: [Install Docker Engine on Ubuntu | Docker Docs](https://docs.docker.com/engine/installation/linux/ubuntulinux/)

you want docker-engine, lxc-docker should be removed.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 7, 2016, 12:03am UTC](https://meta.discourse.org/t/errno-cannot-allocate-memory/43736/14 "2016-05-07T00:03:11Z")

</div>

I believe lxc-docker can be upgraded to 1.9.1 but no higher.

---

<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: [January 16, 2019, 2:52pm UTC](https://meta.discourse.org/t/errno-cannot-allocate-memory/43736/15 "2019-01-16T14:52:41Z")

</div>



---

<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: [January 16, 2019, 7:36pm UTC](https://meta.discourse.org/t/errno-cannot-allocate-memory/43736/16 "2019-01-16T19:36:52Z")

</div>

General solution to this error is adding swap, in some cases you may need a bigger swap

---

<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: [February 15, 2019, 7:36pm UTC](https://meta.discourse.org/t/errno-cannot-allocate-memory/43736/17 "2019-02-15T19:36:52Z")

</div>

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