Automatic service restart

Restart Elasticsearch automatically after a crash

Elasticsearch can be restarted automatically in the event of an error using systemctl. First log in to your Elasticsearch server via ssh and customize the systemctl service.

systemctl edit elasticsearch.service


Editing the service automatically creates an override.conf file in the following directory:

/etc/systemd/system/elasticsearch.service.d/override.conf


Now add the following content to override.conf:

[Service]
Restart=on-failure


Save your changes and use the daemon-reload command for the changes to take effect.

systemctl daemon-reload


Elasticsearch is then automatically restarted by the new configuration file in the event of an error.


You can check whether the new configuration file is already active using the command systemctl status elasticsearch: