Starting Elasticsearch failed

Hi,
Why does the elasticsearch.service status always give me this every time I start/restart my server? .

● elasticsearch.service - Elasticsearch
     Loaded: loaded (/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
     Active: failed (Result: timeout) since Wed 2023-07-05 04:58:42 UTC; 38min ago
       Docs: https://www.elastic.co
    Process: 1421 ExecStart=/usr/share/elasticsearch/bin/systemd-entrypoint -p ${PID_DIR}/elasticsearch.pid --quiet (>
   Main PID: 1421 (code=killed, signal=TERM)
      Tasks: 0 (limit: 38413)
     Memory: 33.8M
     CGroup: /system.slice/elasticsearch.service

Jul 05 04:57:27 srv-elasticsearch systemd[1]: Starting Elasticsearch...
Jul 05 04:58:42 srv-elasticsearch systemd[1]: elasticsearch.service: start operation timed out. Termina>
Jul 05 04:58:42 srv-elasticsearch systemd[1]: elasticsearch.service: Failed with result 'timeout'.
Jul 05 04:58:42 srv-elasticsearch systemd[1]: Failed to start Elasticsearch.

Then afterwards, I always have to restart it manually by running: sudo systemctl restart elasticsearch.service to get it to start.There are no other services running apart from elasticsearch and kibana

My server have this config:

  • 4 CPU
  • 32 GB RAM

Go to /var/log/elasticsearch/<clustername>.log and check messages.

I looked in the logs but everything looked normal, but when I ran

sudo journalctl --unit elasticsearch

it gave me this:

Jul 04 17:25:37 srv-elasticsearch systemd[1]: Stopped Elasticsearch.
-- Reboot --
Jul 05 04:57:27 srv-elasticsearch systemd[1]: Starting Elasticsearch...
Jul 05 04:58:42 srv-elasticsearch systemd[1]: elasticsearch.service: start operation timed out. Termina>
Jul 05 04:58:42 srv-elasticsearch systemd[1]: elasticsearch.service: Failed with result 'timeout'.
Jul 05 04:58:42 srv-elasticsearch systemd[1]: Failed to start Elasticsearch.
Jul 05 05:38:29 srv-elasticsearch systemd[1]: Starting Elasticsearch...
Jul 05 05:38:55 srv-elasticsearch systemd[1]: Started Elasticsearch.

Hi,

I solved the problem by following this post.

Usually ES can start in 30 sec. Maybe CPU is under load or need time to recover indices. However you have solved.