Home Assistant server stopping every few days?

I have installed home assistant to an Android MXQ box with 512Mb RAM. All works really well when it runs. I have some sonoff switches and sockets and some Google assistants connected.
Every few days however it disappears from my network and the only way to access it is pull the plug. It failed last night which meant the dishwasher didn’t run. I have had it running all day and the error log is below.
I really don’t undertstand what most of this means. Could anyone point me to whether this is some memory leak issue or something else unrelated?
Thanks in advance for looking.

2018-08-16 09:25:22 WARNING (Recorder) [homeassistant.components.recorder] Ended unfinished session (id=31 from 2018-08-13 21:48:53.025707)
2018-08-16 09:25:40 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting
2018-08-16 09:47:35 ERROR (Thread-24) [pychromecast.socket_client] Error reading from socket.
2018-08-16 09:47:35 WARNING (Thread-24) [pychromecast.socket_client] Error communicating with socket, resetting connection
2018-08-16 09:47:35 ERROR (Thread-24) [pychromecast.socket_client] Failed to connect, retrying in 5.0s
2018-08-16 09:47:40 ERROR (Thread-24) [pychromecast.socket_client] Failed to connect. No retries.
2018-08-16 09:49:38 ERROR (Thread-26) [pychromecast.socket_client] Error reading from socket.
2018-08-16 09:53:35 ERROR (Thread-27) [pychromecast.socket_client] Error reading from socket.
2018-08-16 09:53:35 WARNING (Thread-27) [pychromecast.socket_client] Error communicating with socket, resetting connection
2018-08-16 09:53:35 ERROR (Thread-27) [pychromecast.socket_client] Failed to connect, retrying in 5.0s
2018-08-16 09:53:40 ERROR (Thread-27) [pychromecast.socket_client] Failed to connect. No retries.
2018-08-16 10:00:35 ERROR (Thread-29) [pychromecast.socket_client] Error reading from socket.
2018-08-16 10:00:35 WARNING (Thread-29) [pychromecast.socket_client] Error communicating with socket, resetting connection
2018-08-16 10:00:35 ERROR (Thread-29) [pychromecast.socket_client] Failed to connect, retrying in 5.0s
2018-08-16 10:00:40 ERROR (Thread-29) [pychromecast.socket_client] Failed to connect. No retries.
2018-08-16 10:25:27 ERROR (MainThread) [homeassistant.components.updater] Got unexpected response: None
2018-08-16 11:11:40 ERROR (Thread-31) [pychromecast.socket_client] Error reading from socket.
2018-08-16 11:11:40 WARNING (Thread-31) [pychromecast.socket_client] Error communicating with socket, resetting connection
2018-08-16 11:11:40 ERROR (Thread-31) [pychromecast.socket_client] Failed to connect, retrying in 5.0s
2018-08-16 11:11:45 ERROR (Thread-31) [pychromecast.socket_client] Failed to connect. No retries.
2018-08-16 11:16:40 ERROR (Thread-33) [pychromecast.socket_client] Error reading from socket.
2018-08-16 11:16:40 WARNING (Thread-33) [pychromecast.socket_client] Error communicating with socket, resetting connection
2018-08-16 11:16:40 ERROR (Thread-33) [pychromecast.socket_client] Failed to connect, retrying in 5.0s
2018-08-16 11:16:45 ERROR (Thread-33) [pychromecast.socket_client] Failed to connect. No retries.
2018-08-16 11:30:31 ERROR (Thread-34) [pychromecast.socket_client] Error reading from socket.
2018-08-16 11:30:32 WARNING (Thread-34) [pychromecast.socket_client] Error communicating with socket, resetting connection
2018-08-16 11:30:32 ERROR (Thread-34) [pychromecast.socket_client] Failed to connect, retrying in 5.0s
2018-08-16 11:30:37 ERROR (Thread-34) [pychromecast.socket_client] Failed to connect. No retries.
2018-08-16 11:57:41 ERROR (Thread-35) [pychromecast.socket_client] Error reading from socket.
2018-08-16 11:57:41 WARNING (Thread-35) [pychromecast.socket_client] Error communicating with socket, resetting connection
2018-08-16 11:57:41 ERROR (Thread-35) [pychromecast.socket_client] Failed to connect, retrying in 5.0s
2018-08-16 11:57:46 ERROR (Thread-35) [pychromecast.socket_client] Failed to connect. No retries.
2018-08-16 11:58:44 ERROR (Thread-36) [pychromecast.socket_client] Error reading from socket.
2018-08-16 11:58:44 WARNING (Thread-36) [pychromecast.socket_client] Error communicating with socket, resetting connection
2018-08-16 11:58:44 ERROR (Thread-36) [pychromecast.socket_client] Failed to connect. No retries.
2018-08-16 14:39:49 ERROR (Thread-37) [pychromecast.socket_client] Error reading from socket.
2018-08-16 14:39:49 WARNING (Thread-37) [pychromecast.socket_client] Error communicating with socket, resetting connection
2018-08-16 14:39:49 ERROR (Thread-37) [pychromecast.socket_client] Failed to connect, retrying in 5.0s
2018-08-16 14:39:54 ERROR (Thread-37) [pychromecast.socket_client] Failed to connect. No retries.
2018-08-16 14:41:52 ERROR (Thread-38) [pychromecast.socket_client] Error reading from socket.
2018-08-16 14:41:52 WARNING (Thread-38) [pychromecast.socket_client] Error communicating with socket, resetting connection
2018-08-16 14:41:52 ERROR (Thread-38) [pychromecast.socket_client] Failed to connect, retrying in 5.0s
2018-08-16 14:41:57 ERROR (Thread-38) [pychromecast.socket_client] Failed to connect. No retries.
2018-08-16 18:24:25 WARNING (MainThread) [homeassistant.components.binary_sensor] Updating ring binary_sensor took longer than the scheduled update interval 0:00:10

I don’t see any suspect issues from your log, but similar to you, my Home Assistant would go offline after a few days. I believe it is because of the poor electrical wiring in my house. My game consoles have unexpectedly shut off randomly, and I had to power cycle my TV a few times because the image became distorted. My Pi with Home Assistant isn’t able to restart properly whenever these suspected surges happen.

I haven’t figured out a solution to this except connect the Raspberry Pi to a wi-fi outlet and turn off/on from there. You could setup the wi-fi outlet to turn off/on nightly, but it wouldn’t completely solve your problem.

@billybob I would check the systems logs for errors.
grep error /var/log/syslog
Can you access the device with keyboard/monitor?

Well the best solution would be to get the wiring fixed but failing that a small UPS (uninterruptible power supply) would smooth out surges and dips on critical equipment.

haha, true, but I rent a room in this house so I won’t be paying to fix their wiring. But now you gave me a reason to buy a UPS, thank you.

Yes I can hook up a keyboard and monitor although I am not there for a few days now. What am I looking for in the logs or should I copy the file out to a USB stick and paste here?

Experienced the same when I was on a raspberry pi. I had the impression (but did not investigate further), that the network stack hung up - the device was powered on but not reachable on the network.

I now have an Intel NUC and HA runs very stable now.

Lars

If you can access the machine, check that you have a network connection. ping would do. ping your router IP address. If that works, check to see if hass is still running

ps -ef |grep hass
You should see a line with pythin3 and hass
I would suspect one or the other has failed. If the network has failed, use the grep command in my earlier post to find error messages. You could post them here but you might be better off posting those questions to the site where you got the OS for your Android box. If hass has failed, then post the error messages from the grep command from my earlier post here.

I had that issue with my HA installation on a Raspberry Pi as well. I setup cron to reboot the machine nightly and it has made my installation much more reliable. Not sure if that can work for you as well but you could give it a try.

@zarthan
Finally got connected up and checked the syslog. The file is empty but there is syslog.1 which had a few unrelated errors.
I then waited for the server to crash which it did today. When I checked, the server is running incredibly slowly. Takes a second even for a character to appear on the line.
I ran the grep error syslog.1 command again and it appears to hang and does not output a result.

Do you have any ideas?

Files in /var/log/ with numbers behind them as in your syslog.1 are older log files that have been rotated out. The current log file in your case will be syslog (no number). You are looking for any errors and while you may not see something as related, it can be that something is crashing and taking other things with it. It can also be that something is running out of control and that nothing gets enough CPU cycles to respond properly.
Output of
ps -ef |grep hass
will tell you if HA is still running.
The output of
top
should show you if anything is consuming lots of CPU time.

I also have problem with spammed log regarding pychromecast.socket_client

Running on Hassio