# "Unable to lock JVM Memory: error=12, reason=Cannot allocate memory"

**URL:** <https://discuss.elastic.co/t/unable-to-lock-jvm-memory-error-12-reason-cannot-allocate-memory/306000>\
**Category:** Elasticsearch\
**Tags:** docker\
**Created:** [May 31, 2022, 6:27am UTC](https://discuss.elastic.co/t/unable-to-lock-jvm-memory-error-12-reason-cannot-allocate-memory/306000 "2022-05-31T06:27:58Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![amitsa](https://avatars.discourse-cdn.com/v4/letter/a/dbc845/32.png) [@amitsa](https://discuss.elastic.co/u/amitsa)\
**Post date:** [May 31, 2022, 6:27am UTC](https://discuss.elastic.co/t/unable-to-lock-jvm-memory-error-12-reason-cannot-allocate-memory/306000/1 "2022-05-31T06:27:58Z")

</div>

I have enabled  
bootstrap.memory\_lock: true

ERROR: [1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.  
bootstrap check failure [1] of [1]: memory locking requested for Elasticsearch process but memory is not locked

I am deploying elastic cluster on kubernetes

```auto
initContainers:
      - name: sysctl
        image: busybox
        imagePullPolicy: IfNotPresent
        command: ["sysctl", "-w", "vm.max_map_count=262144"]
        securityContext:
          privileged: true
      - name: swapiness
        image: busybox
        imagePullPolicy: IfNotPresent
        command: ["sysctl", "-w", "vm.swappiness=1"]
        securityContext:
          privileged: true
      # Increase the max number of open file descriptors.
      - name: increase-fd-ulimit
        image: busybox
        imagePullPolicy: IfNotPresent
        command: ["sh", "-c", "ulimit -n 65535 && ulimit -u 4096 && ulimit -l unlimited"]
        securityContext:
          privileged: true

```

i have tried populating in dockerfile as well

```auto
USER root
RUN echo "Add limits settings ...\n"\
    && echo -e "DefaultLimitNOFILE=65536\nDefaultLimitNPROC=32000\nDefaultLimitMEMLOCK=infinity" >> /etc/systemd/user.conf \
    && echo -e "* soft nofile 65536\n* hard nofile 65536\n* soft nproc 32000\n* hard nproc 32000\n* hard memlock unlimited\n* soft memlock unlimited" >> /etc/security/limits.conf \
    && echo -e "DefaultLimitNOFILE=65536\nDefaultLimitNPROC=32000\nDefaultLimitMEMLOCK=infinity" >> /etc/systemd/system.conf

```

but still not working

---

<div class="post-metadata">

**Author:** ![DineshNaik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dineshnaik/32/89308_2.png) [@DineshNaik](https://discuss.elastic.co/u/DineshNaik)\
**Post date:** [June 1, 2022, 6:22am UTC](https://discuss.elastic.co/t/unable-to-lock-jvm-memory-error-12-reason-cannot-allocate-memory/306000/2 "2022-06-01T06:22:53Z")

</div>

Did you check below thread ?

> [@Elasticserach 7.2 Unable to create cluster with error "Unable to lock JVM Memory: error=12, reason=Cannot allocate memory"](https://discuss.elastic.co/t/elasticserach-7-2-unable-to-create-cluster-with-error-unable-to-lock-jvm-memory-error-12-reason-cannot-allocate-memory/252050/3):
>
> elasticsearch\_1 | {"type": "server", "timestamp": "2020-10-14T13:34:12,750+0000", "level": "INFO", "component": "o.e.p.PluginsService", "cluster.name": "elk-cluster", "node.name": "primary", "message": "loaded module [x-pack-monitoring]" } elasticsearch\_1 | {"type": "server", "timestamp": "2020-10-14T13:34:12,750+0000", "level": "INFO", "component": "o.e.p.PluginsService", "cluster.name": "elk-cluster", "node.name": "primary", "message": "loaded module [x-pack-rollup]" } elasticsea…

---

<div class="post-metadata">

**Author:** ![amitsa](https://avatars.discourse-cdn.com/v4/letter/a/dbc845/32.png) [@amitsa](https://discuss.elastic.co/u/amitsa)\
**Post date:** [June 1, 2022, 7:21am UTC](https://discuss.elastic.co/t/unable-to-lock-jvm-memory-error-12-reason-cannot-allocate-memory/306000/3 "2022-06-01T07:21:06Z")

</div>

yeah i have checked this thread  
how to check if my system supports it or not?

---

<div class="post-metadata">

**Author:** ![ibra\_013](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ibra_013/32/104827_2.png) [@ibra\_013](https://discuss.elastic.co/u/ibra_013)\
**Post date:** [June 1, 2022, 10:53am UTC](https://discuss.elastic.co/t/unable-to-lock-jvm-memory-error-12-reason-cannot-allocate-memory/306000/4 "2022-06-01T10:53:13Z")

</div>

Hi,

Check this ,

> **[Memory lock check | Elasticsearch Guide \[8.2\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/_memory_lock_check.html)**

[https://gemfire.docs.pivotal.io/97/geode/managing/heap\_use/lock\_memory.html](https://gemfire.docs.pivotal.io/97/geode/managing/heap_use/lock_memory.html)

---

<div class="post-metadata">

**Author:** ![amitsa](https://avatars.discourse-cdn.com/v4/letter/a/dbc845/32.png) [@amitsa](https://discuss.elastic.co/u/amitsa)\
**Post date:** [June 1, 2022, 11:42am UTC](https://discuss.elastic.co/t/unable-to-lock-jvm-memory-error-12-reason-cannot-allocate-memory/306000/5 "2022-06-01T11:42:04Z")

</div>

i have followed this approach even with Elasticsearch user and \* . But still it doesn't work

---

<div class="post-metadata">

**Author:** ![vgr](https://avatars.discourse-cdn.com/v4/letter/v/ec9cab/32.png) [@vgr](https://discuss.elastic.co/u/vgr)\
**Post date:** [June 9, 2022, 9:07pm UTC](https://discuss.elastic.co/t/unable-to-lock-jvm-memory-error-12-reason-cannot-allocate-memory/306000/6 "2022-06-09T21:07:02Z")

</div>

Hi, I am facing the same issue even after making all the suggested changes. Did you happen to find any solution?

---

<div class="post-metadata">

**Author:** ![amitsa](https://avatars.discourse-cdn.com/v4/letter/a/dbc845/32.png) [@amitsa](https://discuss.elastic.co/u/amitsa)\
**Post date:** [June 10, 2022, 8:48am UTC](https://discuss.elastic.co/t/unable-to-lock-jvm-memory-error-12-reason-cannot-allocate-memory/306000/7 "2022-06-10T08:48:51Z")

</div>

i see some system doesn't support memory lock as mentioned in few post in community. I went with disabling swap rather than setting bootstrap.memory\_lock: true. I have higher ram nodes with 31gb heap size. so there is now swap happening for me now.

---

<div class="post-metadata">

**Author:** ![vgr](https://avatars.discourse-cdn.com/v4/letter/v/ec9cab/32.png) [@vgr](https://discuss.elastic.co/u/vgr)\
**Post date:** [June 10, 2022, 3:40pm UTC](https://discuss.elastic.co/t/unable-to-lock-jvm-memory-error-12-reason-cannot-allocate-memory/306000/8 "2022-06-10T15:40:37Z")

</div>

I am using CentOS 7. I even tried swapoff -a to disable swap altogether, which doesn't work either.

---

<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:** [July 8, 2022, 3:40pm UTC](https://discuss.elastic.co/t/unable-to-lock-jvm-memory-error-12-reason-cannot-allocate-memory/306000/9 "2022-07-08T15:40:43Z")

</div>

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