# Memory availability error on upgrade

**URL:** <https://forum.ghost.org/t/memory-availability-error-on-upgrade/783>\
**Category:** Developer help\
**Created:** [April 6, 2018, 3:02pm UTC](https://forum.ghost.org/t/memory-availability-error-on-upgrade/783 "2018-04-06T15:02:07Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ted\_hardy](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/ted_hardy/32/353_2.png) [@ted\_hardy](https://forum.ghost.org/u/ted_hardy)\
**Post date:** [April 6, 2018, 3:02pm UTC](https://forum.ghost.org/t/memory-availability-error-on-upgrade/783/1 "2018-04-06T15:02:07Z")

</div>

I’m running two personal sites on a 1GB RAM DigitalOcean droplet and have been for several years (was actually at 512MB droplet until recently). Trying to upgrade from 1.21.6 to 1.22.1. I’m getting an error message now that Ghost recommends you have at least 150MB of memory available for smooth operation. It looks like you have 75 MB available.

Hey, this works just fine and has for a while, so I’ll just upgrade with ‘-force’. Well, that doesn’t work, it skips updating. Ghost Doctor gives me essentially the same error message.

The obvious version would be to upgrade to more than a 1 GB plan, I get it, but this has worked on a much smaller droplet for a long time. Anything I can do to get this to work?

---

<div class="post-metadata">

**Author:** ![vikaspotluri123](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/vikaspotluri123/32/24_2.png) [@vikaspotluri123](https://forum.ghost.org/u/vikaspotluri123)\
**Post date:** [April 6, 2018, 3:08pm UTC](https://forum.ghost.org/t/memory-availability-error-on-upgrade/783/2 "2018-04-06T15:08:03Z")

</div>

So there’s a bug in the memory checker logic because of the way the native free memory library works. There is a fix in progress, but in the meantime you can add the `--no-mem-check` flag to ignore the check

---

<div class="post-metadata">

**Author:** ![ted\_hardy](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/ted_hardy/32/353_2.png) [@ted\_hardy](https://forum.ghost.org/u/ted_hardy)\
**Post date:** [April 6, 2018, 3:12pm UTC](https://forum.ghost.org/t/memory-availability-error-on-upgrade/783/3 "2018-04-06T15:12:30Z")

</div>

That is fantastic. Thanks so much!

---

<div class="post-metadata">

**Author:** ![jlelse](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@jlelse](https://forum.ghost.org/u/jlelse)\
**Post date:** [April 6, 2018, 7:04pm UTC](https://forum.ghost.org/t/memory-availability-error-on-upgrade/783/4 "2018-04-06T19:04:15Z")

</div>

Just use Docker 😉 There you can just pull an updated image…

---

<div class="post-metadata">

**Author:** ![vikaspotluri123](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/vikaspotluri123/32/24_2.png) [@vikaspotluri123](https://forum.ghost.org/u/vikaspotluri123)\
**Post date:** [April 6, 2018, 7:05pm UTC](https://forum.ghost.org/t/memory-availability-error-on-upgrade/783/5 "2018-04-06T19:05:52Z")

</div>

Does docker use `ghost start` in the background? If it does then you’ll have the issue 😉

---

<div class="post-metadata">

**Author:** ![jlelse](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@jlelse](https://forum.ghost.org/u/jlelse)\
**Post date:** [April 7, 2018, 1:24pm UTC](https://forum.ghost.org/t/memory-availability-error-on-upgrade/783/6 "2018-04-07T13:24:46Z")

</div>

No it doesn’t. It uses node directly.

---

<div class="post-metadata">

**Author:** ![vikaspotluri123](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/vikaspotluri123/32/24_2.png) [@vikaspotluri123](https://forum.ghost.org/u/vikaspotluri123)\
**Post date:** [December 4, 2020, 8:10pm UTC](https://forum.ghost.org/t/memory-availability-error-on-upgrade/783/8 "2020-12-04T20:10:26Z")

</div>

Opened on December 4, 2020, 8:10pm UTC



---

<div class="post-metadata">

**Author:** ![ScottSemple](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/scottsemple/32/17035_2.png) [@ScottSemple](https://forum.ghost.org/u/ScottSemple)\
**Post date:** [December 4, 2020, 2:59pm UTC](https://forum.ghost.org/t/memory-availability-error-on-upgrade/783/9 "2020-12-04T14:59:53Z")

</div>

Has [this](https://forum.ghost.org/t/memory-availability-error-on-upgrade/783) returned?

I updated my droplet to Ubuntu 20.04 without any problems. But now when I try to update Ghost, I get the memory error as described in the thread linked above.

Also similar, the `--no-mem-check` flag works.

CC: @vikaspotluri123

---

<div class="post-metadata">

**Author:** ![vikaspotluri123](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/vikaspotluri123/32/24_2.png) [@vikaspotluri123](https://forum.ghost.org/u/vikaspotluri123)\
**Post date:** [December 4, 2020, 8:14pm UTC](https://forum.ghost.org/t/memory-availability-error-on-upgrade/783/10 "2020-12-04T20:14:51Z")

</div>

Can you share the output of `free -h`? We haven’t received any new reports for this. Ghost still requires 150MB free to start

Can you also share your Ghost debug info?

---

<div class="post-metadata">

**Author:** ![ScottSemple](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/scottsemple/32/17035_2.png) [@ScottSemple](https://forum.ghost.org/u/ScottSemple)\
**Post date:** [December 4, 2020, 10:15pm UTC](https://forum.ghost.org/t/memory-availability-error-on-upgrade/783/11 "2020-12-04T22:15:28Z")

</div>

Thanks for getting back to me.

`free -h` is:

` _____ total used free shared buff/cache available`  
`Mem: 981Mi 734Mi 69Mi 1.0Mi 176Mi 99Mi`  
`Swap: 0B 0B 0B`

Next I’ll try `ghost run`?

---

<div class="post-metadata">

**Author:** ![vikaspotluri123](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/vikaspotluri123/32/24_2.png) [@vikaspotluri123](https://forum.ghost.org/u/vikaspotluri123)\
**Post date:** [December 5, 2020, 4:53am UTC](https://forum.ghost.org/t/memory-availability-error-on-upgrade/783/12 "2020-12-05T04:53:50Z")

</div>

Based on the output of `free`, I’m inclined to think that you were legitimately low on memory…

can you try running `free -h` and then immediately running `ghost restart` to see if ghost complains about memory?

If `free + buff/cache >= ~150MB` Ghost should not complain, but there are times where the buff/cache is not accounted in the lib.

`ghost run` should only be used for debugging since there is nothing to restart the Ghost process is if it crashes, and it won’t be running under the correct conditions.

---

<div class="post-metadata">

**Author:** ![ScottSemple](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/scottsemple/32/17035_2.png) [@ScottSemple](https://forum.ghost.org/u/ScottSemple)\
**Post date:** [December 6, 2020, 1:43pm UTC](https://forum.ghost.org/t/memory-availability-error-on-upgrade/783/13 "2020-12-06T13:43:48Z")

</div>

Thanks for your help.

I ran `free -h` and then `ghost restart` without complaints.

I then tried `ghost update` and got the same message (low memory).

---

<div class="post-metadata">

**Author:** ![vikaspotluri123](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/vikaspotluri123/32/24_2.png) [@vikaspotluri123](https://forum.ghost.org/u/vikaspotluri123)\
**Post date:** [December 6, 2020, 5:09pm UTC](https://forum.ghost.org/t/memory-availability-error-on-upgrade/783/14 "2020-12-06T17:09:29Z")

</div>

How much memory does it say you have free?

---

<div class="post-metadata">

**Author:** ![ScottSemple](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/scottsemple/32/17035_2.png) [@ScottSemple](https://forum.ghost.org/u/ScottSemple)\
**Post date:** [December 6, 2020, 10:47pm UTC](https://forum.ghost.org/t/memory-availability-error-on-upgrade/783/15 "2020-12-06T22:47:01Z")

</div>

`It looks like you have ~77.87890625 MB available.`

---

<div class="post-metadata">

**Author:** ![ScottSemple](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/scottsemple/32/17035_2.png) [@ScottSemple](https://forum.ghost.org/u/ScottSemple)\
**Post date:** [January 6, 2021, 11:53am UTC](https://forum.ghost.org/t/memory-availability-error-on-upgrade/783/16 "2021-01-06T11:53:54Z")

</div>

I’m not sure if it’s a best practice or not, but adding a 2GB swap file and adjusting the swappiness to 10 solved this issue.

More info [here](https://linuxize.com/post/how-to-add-swap-space-on-ubuntu-20-04/).

---

<div class="post-metadata">

**Author:** ![ScottSemple](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/scottsemple/32/17035_2.png) [@ScottSemple](https://forum.ghost.org/u/ScottSemple)\
**Post date:** [January 7, 2021, 4:45pm UTC](https://forum.ghost.org/t/memory-availability-error-on-upgrade/783/17 "2021-01-07T16:45:11Z")

</div>

FYI: I think that this should be split into a separate issue, but I didn’t see a way to do that. @vikaspotluri123, is that possible and necessary?

========

Although the memory warnings have stopped with the larger swap file, I used `top` to find out what processes are running. The culprit was `mysqld`, so I logged into the database and looked at the process list.

I have four processes running but I only have two Ghost instances, so I assume that these are unnecessarily doubled, correct? The processes are:

`| Id | User | Host | db | Command | Time | State | Info |`  
`| 29 | [user-12] | localhost:50440 | ghost_production | Sleep | 1113 | | NULL |`  
`| 31 | [user-12] | localhost:50446 | ghost_production | Sleep | 1138 | | NULL |`  
`| 43 | [user-34] | localhost:50510 | domain_com_prod | Sleep | 84 | | NULL |`  
`| 45 | [user-34] | localhost:50530 | domain_com_prod | Sleep | 84 | | NULL | `

If I’m correct to assume that I should only have one process per site running, how do I (safely) kill two of the above and never have them reoccur?

Thanks!

---

<div class="post-metadata">

**Author:** ![vikaspotluri123](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/vikaspotluri123/32/24_2.png) [@vikaspotluri123](https://forum.ghost.org/u/vikaspotluri123)\
**Post date:** [January 7, 2021, 5:29pm UTC](https://forum.ghost.org/t/memory-availability-error-on-upgrade/783/18 "2021-01-07T17:29:34Z")

</div>

It might make sense that there are 2 ghost processes because there’s the `ghost run` process which performs validation (and is relatively lightweight), and the actual Ghost process itself. [ref](https://github.com/TryGhost/Ghost-CLI/blob/master/lib/commands/run.js)

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/kevin/32/32_2.png) [@Kevin](https://forum.ghost.org/u/Kevin)\
**Post date:** [January 8, 2021, 10:03am UTC](https://forum.ghost.org/t/memory-availability-error-on-upgrade/783/19 "2021-01-08T10:03:33Z")

</div>

@ScottSemple those are database connections not outright processes, it’s expected that there are at least 2 per Ghost instance because Ghost uses connection pooling to prevent requests being blocked waiting for database queries to finish. The number of connections will grow under heavier traffic then fall back down to 2 with low traffic.

Database connections are fairly light weight on their own but may have query caches using memory if that memory is freely available. If you have a particularly large site then the mysql memory usage as whole would be higher as more of the database is kept in memory to keep things running smoothly.

You can optimise mysql memory usage for lower-memory systems if needed. There are quite a few generic guides for that from a quick google search but you’ll need to understand your system usage and where potential bottlenecks are based on your specific requirements to avoid causing performance problems.

---

<div class="post-metadata">

**Author:** ![ScottSemple](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/scottsemple/32/17035_2.png) [@ScottSemple](https://forum.ghost.org/u/ScottSemple)\
**Post date:** [January 8, 2021, 2:07pm UTC](https://forum.ghost.org/t/memory-availability-error-on-upgrade/783/20 "2021-01-08T14:07:29Z")

</div>

Thanks, @Kevin. That’s good to know.

Both blogs are small with little traffic. I never had any memory warnings until I upgraded Ubuntu to 20.04. Then I regularly got the sub-150MB warning from Ghost. It never warned on `ghost restart`.

Increasing my swap file to 2GB got rid of the warnings, but usage is still close to 1GB. I haven’t been able to figure out why.

---

<div class="post-metadata">

**Author:** ![Sasha\_Goldstein](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/sasha_goldstein/32/21037_2.png) [@Sasha\_Goldstein](https://forum.ghost.org/u/Sasha_Goldstein)\
**Post date:** [January 8, 2023, 1:37am UTC](https://forum.ghost.org/t/memory-availability-error-on-upgrade/783/22 "2023-01-08T01:37:55Z")

</div>

@ScottSemple Having this exact same issue on Ubuntu 22.04 while upgrading to latest release of Ghost 4 (in prep to jump to v5). Has anyone figured out why memory usage has gotten so high on these version of ubuntu, and how to avoid it?

[Next page](https://forum.ghost.org/t/memory-availability-error-on-upgrade/783.md?page=2)
