# Bootstrap error regarding failure to lock memory

**URL:** <https://discuss.elastic.co/t/bootstrap-error-regarding-failure-to-lock-memory/223572>\
**Category:** Elasticsearch\
**Created:** [March 13, 2020, 8:30pm UTC](https://discuss.elastic.co/t/bootstrap-error-regarding-failure-to-lock-memory/223572 "2020-03-13T20:30:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_finack](https://avatars.discourse-cdn.com/v4/letter/_/e68b1a/32.png) [@\_finack](https://discuss.elastic.co/u/_finack)\
**Post date:** [March 13, 2020, 8:30pm UTC](https://discuss.elastic.co/t/bootstrap-error-regarding-failure-to-lock-memory/223572/1 "2020-03-13T20:30:52Z")

</div>

I have enabled the `bootstrap.memory_lock: true` setting in `elasticsearch.yml`; however, Elasticsearch refuses to start due to failure during bootstrap check because it cannot lock the memory. The log advised the following:

```
[2020-03-13T11:39:56,299][WARN][o.e.b.JNANatives] [hostname] Unable to lock JVM Memory: error=12, reason=Cannot allocate memory
[2020-03-13T11:39:56,303][WARN][o.e.b.JNANatives] [hostname] This can result in part of the JVM being swapped out.
[2020-03-13T11:39:56,304][WARN][o.e.b.JNANatives] [hostname] Increase RLIMIT_MEMLOCK, soft limit: 16777216, hard limit: 16777216
[2020-03-13T11:39:56,305][WARN][o.e.b.JNANatives] [hostname] These can be adjusted by modifying /etc/security/limits.conf, for example:
        # allow user 'elasticsearch' mlockall
        elasticsearch soft memlock unlimited
        elasticsearch hard memlock unlimited
[2020-03-13T11:39:56,306][WARN][o.e.b.JNANatives] [hostname] If you are logged in interactively, you will have to re-login for the new limits to take effect.
[2020-03-13T11:40:08,428][INFO][o.e.b.BootstrapChecks] [hostname] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2020-03-13T11:40:08,474][ERROR][o.e.b.Bootstrap] [hostname] node validation exception
[1] bootstrap checks failed
[1]: memory locking requested for elasticsearch process but memory is not locked

```

I edited `/etc/security/limits.conf` and added the configuration as instructed, but Elasticsearch still fails the bootstrap check due to failure to lock the memory even after a system reboot.

How do I solve this?

Elasticsearch 7.6.1 on Ubuntu 18.04.

---

<div class="post-metadata">

**Author:** ![\_finack](https://avatars.discourse-cdn.com/v4/letter/_/e68b1a/32.png) [@\_finack](https://discuss.elastic.co/u/_finack)\
**Post date:** [March 13, 2020, 9:28pm UTC](https://discuss.elastic.co/t/bootstrap-error-regarding-failure-to-lock-memory/223572/2 "2020-03-13T21:28:53Z")

</div>

I was able to solve the issue on my own via the instructions [here](https://www.elastic.co/guide/en/elasticsearch/reference/master/setting-system-settings.html#systemd).

Essentially:

1. Run `sudo systemctl edit elasticsearch`.

2. Add the following lines to the new file `/usr/lib/systemd/system/elasticsearch.service.d/override.conf`:

3. Run `sudo systemctl daemon-reload`.

4. Restart Elasticsearch.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 10, 2020, 9:29pm UTC](https://discuss.elastic.co/t/bootstrap-error-regarding-failure-to-lock-memory/223572/3 "2020-04-10T21:29:00Z")

</div>

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