HA restart hangs

So I am using HA for almost a year now and I am perfectly happy with it. However one thing is really annoying. Whenever I press restart via the interface it will start to shutdown, but it then throws an error and just hangs (causing me to restart Ubuntu, as force closing it works, but when I just restart HA the frontend won’t be accessible).

So only thing to do is restart Ubuntu which is pretty annoying. Closing it via the console ctrl+c does work every time (if I didn’t press restart via the interface that is).

I don’t understand as the process should be basically the same no? Crazy thing is sometimes I can restart via the interface, sometimes it would just freeze the console. Restarting it via the console works all the time.

Is there anything I can do about this? Or better asked, does anyone else experience this?

What type of HA installation on Ubuntu?

Python venv

I have seen some Hassio installs have on Debian but venv is usually OK.
No errors on processes killed?

Yeah a lot of errors, but it only seems to occur when one of the components fail halfway. In this case the tradfri hub suddenly stopped working (so I had to restart HA) however whenever a component fails it won’t restart via the interface. Doing it with ctrl+c in the console does however.

It is not a big deal though, I have access to all my network resources externally, but it just takes a bit more time to do that instead of just pressing restart :stuck_out_tongue:

Edit: I’d give you an error code, but ofcourse it doesn’t do it now. If it occurs again I will post it here. But the errors are always different. (As if it only occurs on components that failed halfway, while HA is already running)

I’m running HA in a python 3.7 venv on Ubuntu 16.04.
On every restart i see the following errors before HA stops, but i have no problems with the restart.

2019-04-30 23:24:45 WARNING (MainThread) [homeassistant.core] Unable to remove unknown listener <function EventBus.async_listen_once.<locals>.onetime_listener at 0x7f5172d020d0>
2019-04-30 23:24:45 WARNING (MainThread) [homeassistant.core] Unable to remove unknown listener <function EventBus.async_listen_once.<locals>.onetime_listener at 0x7f51726136a8>
2019-04-30 23:24:45 ERROR (MainThread) [coap] Exception CancelledError() can not be represented as errno, setting -1.

Same here. Restart hangs. It worked few days ago then I added my first zwave device now restart hangs. The last thing hass does is writing zwcfg_*.xml.
Ctrl-C does not work.
How can I debug this?

1 Like

It has been a while since I created this thread and I have to admit I did a clean install of Home Assistant a while ago. It is not the solution to my question however it did solve all my problems I had with it. I didn’t really like doing it as it took me a full weekend reconfiguring everything but it works now and haven’t had any problems since. It has been working for a few months now.

Maybe the task for shutting down is waiting for a device and does not get an answer.

Well what I found with the xiaomi Hub is that whenever you restart it will close a socket. If the Xiaomi doesn’t respond or isn’t connected it will look like HA is waiting for that and thus starts to hang. Not entirely sure why it does this behaviour but I had it often with the Xiaomi hub. Though lately it doesn’t seem to do that anymore (the Hub I mean).

It seems to me that it HA will try to close all the connections first before initiating a restart. If it can’t close all the connections it will hang.

Try ctrl+z btw instead of ctrl+c if it doesn’t close. This works for me. However often when this happens many things wont start up again as it says that ports/services are in use already (probably because HA wasn’t shut down properly). I need to restart Ubuntu to get it working again. (I use ubuntu).

A CTRL+Z places the process in the background, it does not close/abort the running task.

You should be using: systemctl restart home-assistant.service to restart Home Assistant when setup properly with a venv install.

1 Like

Did not know this. Thnx, didn’t have any problems after reinstalling though, but this will come in handy in the future.

Jim why don’t you just kill the “hass” process?

Yeah, well, my vm restarts within 5 seconds so not really that big of a deal. And like I said I haven’t had this problem for months now. But thanks a lot for the inputs. Not a big fan of linux but this definitely helps a lot thnx!

I noticed a while ago that after moving to the recommended Python 3.7 zwave would randomly kill Home Assistant.
My personal solution was to move over to OpenHAB. The devs here obviously did not test before making that decision. OH focuses on stability and that is what I need right now.

I use zwave and Python 3.7, no crashes. Sounds like you have other issues at play.

1 Like

I assume you have restart on failure in your service daemon.

As suggested it might be worth doing a fresh install of Hass and copying over your Hass configuration. Some artefacts of older software versions could be causing crashes on your system.

The never ending cycle of updates and breaking changes tends to introduce instability into some users setup. I’ve stopped upgrading at 94.3 as I’m finding it far too time consuming keeping in step with the changes. I’m waiting till v1.00 to revisit the upgrade process.

No restart on failure in my service daemon.

sudo cat /etc/systemd/system/home-assistant.service
[Unit]
Description=Home Assistant
After=network.target

[Service]
Type=simple
User=homeassistant
ExecStart=/srv/homeassistant/venv/bin/hass -c "/home/homeassistant/.homeassistant"

[Install]
WantedBy=multi-user.target
systemctl status home-assistant
● home-assistant.service - Home Assistant
   Loaded: loaded (/etc/systemd/system/home-assistant.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2019-07-01 15:59:09 MST; 3 days ago
 Main PID: 18801 (hass)
   CGroup: /system.slice/home-assistant.service
           └─18801 /srv/homeassistant/venv/bin/python3.7 /srv/homeassistant/venv/bin/hass -c /home/homeassistant/.homeassistant

Just doesn’t crash out for me :man_shrugging: