Home Assistant constantly losing connection - pls help

It was less than a minute. This is not the problem as i have it also with the companion app on Android.
But it was a good suggestion and to be honest i was not aware of this setting. However i will turn this setting off to see if it makes a difference.

1 Like

Hi have you found a fix for this? My HA has been kept disconnecting for monthsā€¦
Log says:

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/http.py:519
integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 2:03:36 PM (3 occurrences)
Last logged: 2:39:41 PM

[546351994416] from 127.0.0.1 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36): Disconnected: Did not receive auth message within 10 seconds
[546173647552] from 127.0.0.1 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36): Disconnected: Did not receive auth message within 10 seconds
[546173639344] Victoria from 127.0.0.1 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36): Disconnected: Received non-Text message.

This is not the problem as i have it also with the companion app on Android

Yeah, it doesnā€™t seem to be an issue on the client side because the companion app, browsers on other machines also fail at the same time. FWIW, Iā€™m also running HA on proxmox.

The logs donā€™t indicate a restart of the home assistant server, just all network requests timeout to the server, and all the integrations which depend on the network throw errors relating to the connection being down. Eventually it will randomly come back on but thereā€™s nothing consistent in the logs that seem related to the connection going down or coming back up

1 Like

The logs donā€™t indicate that there is a restart, the connection just seems to randomly get restored and things go back to normal. This is really frustrating. It seems like about 50% of the time when I go to open home assistant or expect an automation to fire it wonā€™t work because the connection is down. Iā€™ve tried removing all custom components and starting fresh then restoring from backup and I see the same behavior

I had an inkling that this was related to my use of auto-entities - the more of my auto-entities cards I have disabled, the less I have experienced these issues.

I have also seen this happen fairly consistently when working with heavy lifting templates in the developer tools (before they get optimized)

When it happens, almost all of my ZHA entities become unavailable, logging usually continues for a while, sometimes the system recovers, sometimes it restarts.

This is FAR more likely to happen after a ā€˜restartā€™ than after a hard-reboot

Whatā€™s an ā€œauto-entityā€?

I was logging my Home Assistant restarts to see if it was happening often. It isnā€™t, but it is happening too often to ignore.

HA started on Tue Oct 15 11:29:12 EDT 2024
HA started on Tue Oct 15 12:27:22 EDT 2024
HA started on Tue Oct 15 14:35:55 EDT 2024
HA started on Tue Oct 15 22:42:42 EDT 2024
HA started on Tue Oct 15 22:50:52 EDT 2024
HA started on Wed Oct 16 00:18:08 EDT 2024
HA started on Wed Oct 16 12:21:05 EDT 2024
HA started on Thu Oct 17 09:58:29 EDT 2024  I restarted HA
HA started on Thu Oct 17 10:19:52 EDT 2024
HA started on Thu Oct 17 22:16:48 EDT 2024
HA started on Fri Oct 18 18:01:53 EDT 2024
HA started on Fri Oct 18 23:18:11 EDT 2024

Only once in the past three days did I manually restart Home Assistant.

auto-entities is a custom card

I was seeing tons of failed connections related to it in the developer-tools of my browser, but I cannot be sure if they are the cause of the networking overloading or just a victim

Likewise, I have been logging my shutdown and startup - several consecutive starts over the last few days where the shutdown did not get logged as the restart was not initiated by me.

2024-10-14 03:48:16.186: ------ Home Assistant is shutting down -----
2024-10-14 03:53:09.349: ------ Home Assistant is Starting -----
2024-10-14 09:31:15.483: ------ Home Assistant is Starting -----
2024-10-14 13:28:45.483: ------ Home Assistant is shutting down -----
2024-10-14 13:31:31.143: ------ Home Assistant is Starting -----
2024-10-14 18:15:26.482: ------ Home Assistant is shutting down -----
2024-10-14 18:20:29.595: ------ Home Assistant is Starting -----
2024-10-15 22:51:36.936: ------ Home Assistant is Starting -----
2024-10-18 01:53:42.364: ------ Home Assistant is Starting -----
2024-10-18 06:05:26.635: ------ Home Assistant is shutting down -----
2024-10-18 06:10:31.332: ------ Home Assistant is Starting -----
2024-10-18 16:52:32.288: ------ Home Assistant is shutting down -----
2024-10-18 16:54:59.872: ------ Home Assistant is Starting -----
2024-10-18 21:02:29.403: ------ Home Assistant is shutting down -----
2024-10-18 21:07:27.493: ------ Home Assistant is Starting -----

I am seeing a similar pattern, but not as frequent. What I AM seeing is Home Assistant restarting spontaneously. But it weird since the restart is not logged. I just know itā€™s happening if I see the ā€œConnection Lostā€ while editing an ESPHome configuration. I am sure that Home Assistant, not my browser, is the problem because when I see ā€œConnection Lostā€, the status LED on my ESPHome devices start blinking. (I have seven on my workbench- part of a big Halloween experience).

Same here for about the past month but nothing showing in the logs. My Rpi has been very stable for over a year but no more. Loaded HAOS on a spare laptop which is now my master.

I know, from my experience, that saving a new ESPHome configuration is very CPU intensive on a RPi

It seems, that in many cases cited here, that the UI hangs when the back-end is busy processing something.

I find that the following all cause the same issue with the front-end losing connection and other back-end network connected integrations failing.

  1. High/Heavy use of jinja templates in Lovelace (especially those not optimized)
  2. Reloading templates from developer tools
  3. Saving ESPHome configurations
  4. Joining a new Device on ZHA (this seems to cause very ZigBee device to go temporarily unavailable and throw the UI into a loop)
  5. Heavy lifting time triggered automations that are spread out in runtime, but can occasionally, periodically, apocalyptically fall in sync with each other and execute simultaneously :slight_smile:

Side note: In trying to diagnose the problem and log more information about unexpected shutdowns I started watching the logs using the system_log integration.

###########################################
#  Fire events each time the log file gets written
# ##########################################
system_log:
  fire_event: true

After I added the above to my configuration (plus an automation and a few counters to count problems), my RPi started rebooting even more frequently. Why?: Well because, 1457k database events and counter updates got recorded in the database in 16 hours :slight_smile: . Sometimes adding more database input/output to an unstable system just rocks the boat. I counterbalanced that oversight with this.

recorder:
  exclude:
    event_types:
    - system_log_event
    entities:
    - counter.system_log_error_counter
    - counter.system_log_warning_counter

3 Years into this now - still a learning curve. My main takeaway is that 9 times out of 10, I caused the problemā€¦

ā€œitā€™s me, hi, Iā€™m the problem itā€™s meā€ - Tailor Sniff

Thanks for the input. I am not using a Pi, but an Intel NUC. My problem is that I get ā€œconnection lostā€ spontaneously even when doing nothing.

Just throwing my hat into the ring on this one as well. It started a few days ago. Running HA in Proxmox on a Lenovo Tiny. Things will just stop responding and if I use the companion app or browser, I get the Connection Lost message. Proxmox says HA is up and running with no restarts. A restart can sometimes get it to work again for a while, and then the lost connections start again. Alexa canā€™t control devices and Iā€™m assuming thatā€™s because she canā€™t connect to my HA instance.

To me it seems Home Assistant just keeps disconnecting for no reason at all. I have tried rolling back Alexa Media Player to the earlier version, in hopes that that will help, but it still appears that Iā€™m having disconnections. Everything had been working great for MANY years (5 or more) and now itā€™s just a frustrating mess of lost connections.

Yeah, that was the same as me. Running on proxmox for years without any issue. Havenā€™t even really tinkered with it much over the past year or so and the only real changes have been updates. Unfortunately I just scrapped my instance all together because it was too frustrating. I started and configured a new instance of Home Assistant just to host a critical automation, but I might take this as an opportunity to look at other options

I recognise this is a very old post but Iā€™m struggling with the ā€˜Connection Lost. Reconnectingā€¦ā€™ error for weeks and your response may be the solution.

I had a look at the browser console as the connection died

Does this mean the issue can be traced back to http://192.168.2.99:8123/customcards/github/gadgetchnnel/lovelace-text-input-row.js?track=true?

Donā€™t really understand this

FWIW Iā€™m still getting this and landed here in search of an answer. Itā€™s getting pretty damn annoying.

Iā€™ve not got any particularly crazy dashboards (I havenā€™t played THAT MUCH with them yet, just using a new sections view of rooms where someone currently is). Donā€™t think I even have ANY custom elements.

Just keep getting [Websocket died, forcing reconnectā€¦] at random intervals and sometimes a age reconnects and loads, other times I get bored of waiting and refresh the window and it usually comes back after a second or two.

1 Like

Same here still trying to chase it down.

One thing I managed to just prove somewhat randomly (and more than once in a row) is that it is a server issue, it appears as though the entire thing locks up briefly.

I just had my laptop open in my kitchen where I have an Aqara FP2 which lights up several lights as I walk around, and as I walked through none of them turned on. I turned to look at my laptop which had the HA UI open and spotted the dreaded ā€œReconnectingā€¦ā€ message. I stood in place for a few seconds until the UI reconnected to the web socket, and as it did the lights came on in perfect unison.

Itā€™s happening to me (websocket goes down) when my ZHA integration reboots/reloads/restarts because of a watchdog failure

What is causing that I have still not discovered, but when it happens I get a few thousand of the browser console messages illustrated by Thomas Meier

I feel that this in turn may be hammering the back-end and bringing it to its knees as it usually never recovers - Itā€™s probably still running but all Back-End to UI communications seem to be lost and I often have to reboot the host system unless it seems to realize that it should reboot itself

Iā€™ve never had to reboot the host computer. I just wait a few seconds for ā€œReconnectingā€¦ā€ to finish.

1 Like

Same here, always reconnects after a few seconds (maybe 5-20 sometimes). But Iā€™ve definitely noticed automations being affected and them both recovering at the exact same time.