Query Failed [Failed to execute main query] OutOfMemoryError: Java heap space Query Failed [Failed to execute main query] OutOfMemoryError: Java heap space elasticsearch elasticsearch

Query Failed [Failed to execute main query] OutOfMemoryError: Java heap space


UPDATE: ES_HEAP_SIZE is no longer a documented option

Elastic Search won't use all of that memory without being configured.

You need to configure and tune Elastic Search and Debian's memory settings.

You'll need to configure one of these:

  • /etc/elasticsearch/jvm.options: a file containing JVM options (file is at config/jvm.options (in a TAR or ZIP distro rather than a Debian package)
  • ES_JAVA_OPTS: an environment variable with additional JVM settings including memory and GC tuning if needed (pretty much what's in jvm.options but in a single line separated by spaces)

Here's the relevant excerpt from Elastic's latest documentation as of February 2020:

Here are examples of how to set the heap size via the jvm.options file:

-Xms2g ①-Xmx2g ②
  • ① Set the minimum heap size to 2g.
  • ② Set the maximum heap size to 2g.

It is also possible to set the heap size via an environment variable. This can be done by commenting out the Xms and Xmx settings in the jvm.options file and setting these values via ES_JAVA_OPTS:

ES_JAVA_OPTS="-Xms2g -Xmx2g" ./bin/elasticsearch ①ES_JAVA_OPTS="-Xms4000m -Xmx4000m" ./bin/elasticsearch ②
  • ① Set the minimum and maximum heap size to 2 GB.
  • ② Set the minimum and maximum heap size to 4000 MB.

See more here:


Seems like you don't have enough space for Java's heap.Since it seems like you'd have more hardware wise you may try to increase it:Increase heap size in Java