# CSCLI Machines list No Heartbeat after lxc container Restart

**URL:** <https://discourse.crowdsec.net/t/cscli-machines-list-no-heartbeat-after-lxc-container-restart/1969>\
**Category:** Uncategorized\
**Created:** [August 17, 2024, 10:01am UTC](https://discourse.crowdsec.net/t/cscli-machines-list-no-heartbeat-after-lxc-container-restart/1969 "2024-08-17T10:01:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benjamin](https://avatars.discourse-cdn.com/v4/letter/b/3d9bf3/32.png) [@Benjamin](https://discourse.crowdsec.net/u/Benjamin)\
**Post date:** [August 17, 2024, 10:01am UTC](https://discourse.crowdsec.net/t/cscli-machines-list-no-heartbeat-after-lxc-container-restart/1969/1 "2024-08-17T10:01:44Z")

</div>

Hello, I have a Crowdsec main server local that runs on an LXC container Proxmox Debian 12 and then I have other servers that are connected to the main server.  
I have the problem that after a Proxmox restart my servers always have no heartbeat except for the main server (192.168.177.xx local api).

Does anyone know where the error is?

If I delete the machine and create it again (sudo cscli machines validate) then it shows me a heartbeat but only until I restart again, after which there is no more heartbeat.

---

<div class="post-metadata">

**Author:** ![iiAmLoz](https://dub1.discourse-cdn.com/flex013/user_avatar/discourse.crowdsec.net/iiamloz/32/386_2.png) [@iiAmLoz](https://discourse.crowdsec.net/u/iiAmLoz)\
**Post date:** [August 19, 2024, 8:05am UTC](https://discourse.crowdsec.net/t/cscli-machines-list-no-heartbeat-after-lxc-container-restart/1969/2 "2024-08-19T08:05:36Z")

</div>

On the LXC are you persisting the `/etc/crowdsec` directory, this is where the configuration files are held and if they are not persisted after a reboot it will wipe them.

---

<div class="post-metadata">

**Author:** ![Benjamin](https://avatars.discourse-cdn.com/v4/letter/b/3d9bf3/32.png) [@Benjamin](https://discourse.crowdsec.net/u/Benjamin)\
**Post date:** [August 19, 2024, 6:12pm UTC](https://discourse.crowdsec.net/t/cscli-machines-list-no-heartbeat-after-lxc-container-restart/1969/3 "2024-08-19T18:12:20Z")

</div>

Hello, thank you very much. I don’t understand exactly what I have to do. Can the main server on which the local API runs not start or do I have to store the folder on an external storage device such as a NAS?

etc in Mainserver my local api:

 ![MainServer local api](https://europe1.discourse-cdn.com/flex013/uploads/crowdsec/original/1X/7aac7cc8ef0d0515c32f1a30aa78864e48ce1de6.png)

etc in Server:

 ![Server](https://europe1.discourse-cdn.com/flex013/uploads/crowdsec/original/1X/2e70c5a2cdde763a277864d30fec79d784eb3ae1.png)

---

<div class="post-metadata">

**Author:** ![Benjamin](https://avatars.discourse-cdn.com/v4/letter/b/3d9bf3/32.png) [@Benjamin](https://discourse.crowdsec.net/u/Benjamin)\
**Post date:** [August 26, 2024, 9:09pm UTC](https://discourse.crowdsec.net/t/cscli-machines-list-no-heartbeat-after-lxc-container-restart/1969/4 "2024-08-26T21:09:59Z")

</div>

Hi have you any Idea ? If I Reboot the files are not wiped.

---

<div class="post-metadata">

**Author:** ![Benjamin](https://avatars.discourse-cdn.com/v4/letter/b/3d9bf3/32.png) [@Benjamin](https://discourse.crowdsec.net/u/Benjamin)\
**Post date:** [August 26, 2024, 10:31pm UTC](https://discourse.crowdsec.net/t/cscli-machines-list-no-heartbeat-after-lxc-container-restart/1969/5 "2024-08-26T22:31:56Z")

</div>

Update: I Got this Error on all Server who not work after Reboot:  
systemctl status crowdsec  
Aug 27 00:55:46 AdGuard systemd[1]: Starting crowdsec.service - Crowdsec agent…  
Aug 27 00:55:46 AdGuard crowdsec[151]: time=“2024-08-27T00:55:46+02:00” level=fatal msg=“unable to start crowdsec routines:authenticate watcher (da7db0d5e1f14d77a2dded5aef8843b3tHRUQic3GdGrfqv): Post"[http://192.168.178.xx](http://192.168.178.xx):xxxx/v1/watchers/login": performing jwt auth: dial tcp 192.168.178.xx:xxxx: connect: connection refused”  
Aug 27 00:55:46 AdGuard systemd[1]: crowdsec.service: Control process exited, code=exited, status=1/FAILURE  
Aug 27 00:55:46 AdGuard systemd[1]: crowdsec.service: Failed with result ‘exit-code’.  
Aug 27 00:55:46 AdGuard systemd[1]: Failed to start crowdsec.service - Crowdsec agent.

When i try  
sudo systemctl restart crowdsec  
all works fine.

---

<div class="post-metadata">

**Author:** ![iiAmLoz](https://dub1.discourse-cdn.com/flex013/user_avatar/discourse.crowdsec.net/iiamloz/32/386_2.png) [@iiAmLoz](https://discourse.crowdsec.net/u/iiAmLoz)\
**Post date:** [August 27, 2024, 2:09pm UTC](https://discourse.crowdsec.net/t/cscli-machines-list-no-heartbeat-after-lxc-container-restart/1969/6 "2024-08-27T14:09:21Z")

</div>

So from the last error from `AdGuard` maybe your lxc’s are coming up in an order when one is reliant on another and because the main LAPI is not coming up first the rest fail.

---

<div class="post-metadata">

**Author:** ![Benjamin](https://avatars.discourse-cdn.com/v4/letter/b/3d9bf3/32.png) [@Benjamin](https://discourse.crowdsec.net/u/Benjamin)\
**Post date:** [September 3, 2024, 4:17pm UTC](https://discourse.crowdsec.net/t/cscli-machines-list-no-heartbeat-after-lxc-container-restart/1969/7 "2024-09-03T16:17:56Z")

</div>

Hi thanks,  
i tryed this in the crowdsec.service of my main Lapi (CrowdSec Main Server)

[Unit]  
Description=Crowdsec agent  
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]  
Type=notify  
Environment=LC\_ALL=C LANG=C  
PIDFile=/var/run/crowdsec.pid  
ExecStartPre=/usr/bin/crowdsec -c /etc/crowdsec/config.yaml -t  
ExecStart=/usr/bin/crowdsec -c /etc/crowdsec/config.yaml -no-api  
#ExecStartPost=/bin/sleep 0.1  
ExecReload=/bin/kill -HUP $MAINPID  
Restart=on-failure  
RestartSec=5s

[Install]  
WantedBy=multi-user.target

I added:  
Restart=on-failure  
RestartSec=5s

and now it Works fine. Is this a good Solution ?
