# Kibana sporadically crashing and not automatically recovering even though the correct systemd UNIT file is in place

**URL:** <https://discuss.elastic.co/t/kibana-sporadically-crashing-and-not-automatically-recovering-even-though-the-correct-systemd-unit-file-is-in-place/172717>\
**Category:** Kibana\
**Created:** [March 18, 2019, 7:43am UTC](https://discuss.elastic.co/t/kibana-sporadically-crashing-and-not-automatically-recovering-even-though-the-correct-systemd-unit-file-is-in-place/172717 "2019-03-18T07:43:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas.heuberger](https://avatars.discourse-cdn.com/v4/letter/t/e8c25b/32.png) [@thomas.heuberger](https://discuss.elastic.co/u/thomas.heuberger)\
**Post date:** [March 18, 2019, 7:43am UTC](https://discuss.elastic.co/t/kibana-sporadically-crashing-and-not-automatically-recovering-even-though-the-correct-systemd-unit-file-is-in-place/172717/1 "2019-03-18T07:43:56Z")

</div>

So, from time to time Kibana sporadically crashes and the service is not automatically restarted, even though the correct systemd UNIT file is in place.

```
:~$ cat kibana.service
[Unit]
Description=Kibana
StartLimitIntervalSec=30
StartLimitBurst=3

[Service]
Type=simple
User=kibana
Group=kibana
# Load env vars from /etc/default/ and /etc/sysconfig/ if they exist.
# Prefixing the path with '-' makes it try to load, but if the file doesn't
# exist, it continues onward.
EnvironmentFile=-/etc/default/kibana
EnvironmentFile=-/etc/sysconfig/kibana
ExecStart=/usr/share/kibana/bin/kibana "-c /etc/kibana/kibana.yml"
Restart=always
WorkingDirectory=/

[Install]
WantedBy=multi-user.target
root@inpunpr13:/etc/systemd/system#

```

yet:

```
:~$ systemctl status kibana
● kibana.service - Kibana
   Loaded: loaded (/etc/systemd/system/kibana.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Sat 2019-03-16 16:37:19 CET; 1 day 15h ago
 Main PID: 39453 (code=exited, status=0/SUCCESS)

```

and

```
:~$ systemctl show kibana.service -p NRestarts
NRestarts=0

```

Any idea how to prevent / mitigate this? I know this is rather a systemd question than a Kibana question, but I thought that probably somebody encountered this problem as well.

Thanks!

---

<div class="post-metadata">

**Author:** ![tiagocosta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tiagocosta/32/40045_2.png) [@tiagocosta](https://discuss.elastic.co/u/tiagocosta)\
**Post date:** [March 18, 2019, 11:09am UTC](https://discuss.elastic.co/t/kibana-sporadically-crashing-and-not-automatically-recovering-even-though-the-correct-systemd-unit-file-is-in-place/172717/2 "2019-03-18T11:09:17Z")

</div>

@thomas.heuberger can you try to add `RestartSec=5` under the `[Service]` section of your `kibana.service`?

---

<div class="post-metadata">

**Author:** ![thomas.heuberger](https://avatars.discourse-cdn.com/v4/letter/t/e8c25b/32.png) [@thomas.heuberger](https://discuss.elastic.co/u/thomas.heuberger)\
**Post date:** [March 18, 2019, 12:42pm UTC](https://discuss.elastic.co/t/kibana-sporadically-crashing-and-not-automatically-recovering-even-though-the-correct-systemd-unit-file-is-in-place/172717/3 "2019-03-18T12:42:38Z")

</div>

I modified kibana.service to

```
:~# cat /etc/systemd/system/kibana.service
[Unit]
Description=Kibana
StartLimitIntervalSec=30
StartLimitBurst=5

[Service]
Type=simple
User=kibana
Group=kibana
# Load env vars from /etc/default/ and /etc/sysconfig/ if they exist.
# Prefixing the path with '-' makes it try to load, but if the file doesn't
# exist, it continues onward.
EnvironmentFile=-/etc/default/kibana
EnvironmentFile=-/etc/sysconfig/kibana
ExecStart=/usr/share/kibana/bin/kibana "-c /etc/kibana/kibana.yml"
Restart=always
RestartSec=30
WorkingDirectory=/

[Install]
WantedBy=multi-user.target

```

and that seemes to do the trick. I'm not sure why it didn't work without explicitly setting  
`RestartSec`

---

<div class="post-metadata">

**Author:** ![tiagocosta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tiagocosta/32/40045_2.png) [@tiagocosta](https://discuss.elastic.co/u/tiagocosta)\
**Post date:** [March 18, 2019, 3:07pm UTC](https://discuss.elastic.co/t/kibana-sporadically-crashing-and-not-automatically-recovering-even-though-the-correct-systemd-unit-file-is-in-place/172717/4 "2019-03-18T15:07:36Z")

</div>

@thomas.heuberger awesome! Maybe we can mark the answer as the solution until we permanently fix that?

Also it would be very cool to know what is the kibana version you are running right now 🙂

---

<div class="post-metadata">

**Author:** ![thomas.heuberger](https://avatars.discourse-cdn.com/v4/letter/t/e8c25b/32.png) [@thomas.heuberger](https://discuss.elastic.co/u/thomas.heuberger)\
**Post date:** [March 19, 2019, 1:19pm UTC](https://discuss.elastic.co/t/kibana-sporadically-crashing-and-not-automatically-recovering-even-though-the-correct-systemd-unit-file-is-in-place/172717/5 "2019-03-19T13:19:16Z")

</div>

```
:~$ /usr/share/kibana/bin/kibana --version
6.6.2
```

---

<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:** [April 16, 2019, 1:19pm UTC](https://discuss.elastic.co/t/kibana-sporadically-crashing-and-not-automatically-recovering-even-though-the-correct-systemd-unit-file-is-in-place/172717/6 "2019-04-16T13:19:29Z")

</div>

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