Given: your VM is on ubuntu 16.04 And: you had installed your ElasticSearch with command:

sudo apt-get install default-jre
sudo apt-get install default-jdk
cd /tmp
echo "deb stable main" |
sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list
sudo apt-get update && sudo apt-get install elasticsearch
sudo systemctl enable elasticsearch.service

When you are getting error:

sudo service elasticsearch status

● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service;
enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2017-10-23 06:29:14 UTC;
2s ago
  Process: 27700 ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p
${PID_DIR}/ --quiet -Edefault.path.logs=${LOG_DIR}${DATA_DIR} -Edefault.path.conf=${CONF_DIR}
(code=exited, status=1/
  Process: 27696
(code=exited, status=0/SUCCESS)
 Main PID: 27700 (code=exited, status=1/FAILURE)

Then you need to change default Java heap memory size for elastic search (default is 2GB)

vim /etc/elasticsearch/jvm.options

…and change

# ...


# ...

# ...


# ...

this will change heap to 200 MB, you can decrease even more

After this restart elasticsearch

sudo service elasticsearch start
sudo service elasticsearch status  # should be OK now