STOP / RESTART of service takes loooong time

In the past month or so I see a significant increase in the time it take HA to execute Stop service / Restart service commands (via command line / developer tools bar).
it seems like the service may be hang on something / waiting for something… not sure but it takes several minutes where in the future it was seconds / up to a minute - tops.

Is this related to some specific automation? timed automation maybe? custom components I have?

(Running on PI3,
I’ve switched to MySQL thinking it was the DB but that did not seem to help,
same for playing with purge days parameter )

Any idea how I can troubleshoot this?

Do you have the same waiting time if you go into command line and “sudo kill $PID” HA?


Can you share some of your log to see what HA is doing when restarting.
For me i only have DarkSky and Netgear router login that take time, the rest is quick.

Starting from version 36.0 or 36.1, my HASS is hanging on in 90% of cases if I restarted it in Dev tool as well as if I try to stop service in command line.
I also moved to MySQL (from 36.1) but it doesn’t help or, maybe, it triggered that behaviour.

The basic Kill command was ignored, adding “-9” signal did the job immediately.
in long run use, are there any down sides to this (other than it being less friendly with having to check the PID first etc)?

sudo kill -9 <$PID>

My configuration is pretty complex I guess but the increase shutdown time happened almost over night I think…

Please note I am talking specifically about Shutdown sequence - not the Start sequence.

I have Netgear as well (not defined in the configuration - relying on auto discovery) and Darksky, tried to remove DarkSky - no noticeable effect sadly.

Well…As someone on the internet once said:
sudo kill is basically asking the process to please finish now where sudo kill -9 is telling the os to slit the processes throat. So yeah you should not do that if you don’t have to. It could possibly corrupt your database and various other things.


1 Like

Funny but apt example…

Do you have a lot of template sensors? Just curious as I used to have a lot more templates when I was running a custom version of the WeatherUnderground component before it was integrated and shutdowns always seemed to take a lot longer.

Also, I think that shutdowns always take longer if you are doing a restart just after starting up because some of the init tasks that are queued up still need to get to a breakpoint where they respond to the shutdown.

I think it waits for any timed automations that are in process already before the shutdown signal, as well. If, for example, you have a script that pings a remote machine to check for a connection - it would wait until the command returns cleanly before exiting.

Yes you are talking about restart, and i agree with the other answers here that some things could have been queued up and the shutdown will wait for those to finish; like for example netgear, if this is busy at the moment you are restarting HA will wait for this.
Do you think it i still possible to copy/paste or email the piece of the log that is part of the ‘restart’ ?