Home Assistant sporadically loose connection to internet services

My HA instance has for some weeks know sporadically lost connection to different internet resources, including Nabu Casa. Also weather service and other API is losing connection. But I can connect to HA locally, and I also have a Ping to Cloudflare DNS, and that does not gets disconnects.
After a restart of HA (not hw) all is fine for some time and then I lose connection again.
I am running HAOS on Genric_x86 and it has been working for years know. But this started around start of september.
My network is Unifi and I have a static IP set in the Unifi controller (not in HA).
I can’t seem to find anything in the logs, so could someone help on how to proceed troubleshooting?

If you have a coin cell battery in the machine, then replace that.
It sounds like the RTC might have wrong time set, which can happen when the battery has died.

I will check that. But just out of curiosity, how does the RTC in the BIOS affect the internet connectivity?

HTTPS is encrypted and encryption have a timestamp, which prevents a malicious actor from recording a connections packets and then send them later.
If the time is more than usually 5 minutes off from the timestamp then the connection is assumed being a replay attack and it is dropped.

HA do regular syncs with time servers on the internet, which I think is each couple of hours, and it also do a sync on a restart. The connection will work after this syncs, but if the battery is making the RTC malfunction, then it will eventually be out of sync again soon.
This fits with your description of sporadic dropouts and a restart solving it for some time.

2 Likes

Hi

I have now changed the battery, but it has not helped. Does anybody knows if there is some logs I should pay attention to?

//Lasse

There might be logs for link on the cable/WiFi, but that does really not say much.

You need to make your own tests, like ping different sources over time and write it to a file.
You would need to ping from your HA machine and from a workstation on same network.
You would on both machines need to ping

  • the other machine to see if the issue is internal
  • the internal router IP to see if it is the router
  • the external router IP to see if it is the routing inside the router
  • first hop outside the router to see if it is your internet connection
  • first hop outside your ISP’s network, especially if your are behind CGNAT, to see if it is them that has an issue
  • public available IP, like 1.1.1.1 (Cloudflare DNS) and 8.8.8.8 (Google DNS) and maybe some extra like 2.23.172.114 (dr.dk) to see if it is an issue on the general internet.
  • if you can, then also ping the internet services that are causing the problem, but some might prevent pings

This will show you if there is a connection issue somewhere, but it will not show you issues with DNS lookup, which must be done afterwards and in the moment your internet services have issues.