Home Assistant won't connect after ISP router switched off

Hello everyone,

This is my first post so I am hope I am doing things right, ie using the right category and giving the right amount of info! I have read through the “help us help you guide”.

I have followed various tutorials on how to set up my Home Assistant OS on my Raspberry Pi 4 and got it up and running using one seamless URL for both when in the local network and out of it too, using a duckdns link.

However, when I left my flat for a few days I switched off my ISP router. When I came back I switched it back on but I noticed that I could not connect to my URL any longer. I got the typical:
Unable to connect to Home Assistant.

I tried typing in directly the IP address but same result.

This happened to me once before and I remember solving it by plugging my TV screen and a keyboard into my raspberry pi, and attempting some things using the command line interface. What worked in the end I believe was to do a:
ha core rebuild

But I lost everything and had to restart everything from scratch, relink with my devices, redo my automations etc etc. I don’t seem to have many options because I feel like I’m locked out. Can’t do anything from my PC/phone as it won’t connect…

I am using Home Assistant OS 8.5.

  • is there anything silly I am missing here?
  • should it be avoided to switch off my ISP router for a few days?
    I have not found much regarding this issue in the documentation…

Many thanks for your help!
Have a nice day

Thomas

HA OS on a Pi does not like an Ethernet disconnect, e.g. only a restart makes it connect again.

it does not hurt, as long as there is a switch between the Pi and the router, and the switch is not turned off.
If the Pi is directly connected to the router, I would not turn it off.

Hi,
There’s likely a few networking things going on here which you’d hope would come back automatically, but don’t always.

I’m assuming you know an IP address and some sysadmin as you mention setting up DuckDNS (implying NAT and other router stuff).

  • The ISP router likely runs a DHCP server to hand out IPv4 addresses (like 192.168.0.123) to both HAOS in the RPi4 and your other devices.
    These leases typically last 24h, so turning the router off for days will have forced HAOS to remove the IPv4 address it was given.
    IPv6 may still work via link-local addressing.
  • Using an address like http://homeassistant.local:8123 uses mDNS (AKA Bonjour) which also times out after a while.

You did the right thing remembering the LAN IPv4 for HASS, and trying it directly. This usually works for me if the router / DHCP server fails but that’s after 10 minutes, not after the 24h lease times out.

I’ve seen HAOS mDNS issues fixed by un-plugging a live Ethernet cable, then re-connecting as this ifdown usually kicks Linux into reconfiguring DHCP, DNS, routing, and mDNS.

Sometimes IPv6 works with broken IPv4 - try a phone, tablet, desktop as each OS can react differently.

Getting a console and entering ha core rebuild is the same as a factory reset, so without a local backup, that’ll wipe everything.

I’ve not had to use the HAOS console for years, but think you can get to the HASS (notice the difference - HASS runs on a VM on HAOS) Linux command line and the HAOS shell to check networking (gets complex as HAOS is a router with internal VM addresses).

I’d recommend installing some common tools so you more easily see what’s going on when things are working (although not network specific):

  • Add-on: File editor, SettingsAdd-onsAdd-on store., “File editor” - useful to see behind the GUI
  • Add-on: HASS web shell The Home Assistant CLI shows the HASS command line.
  • Add-on: Samba share - one way of copying off backups and other media (although I tend to use the command line and scp)

Get comfortable connecting and downloading backups to another machine - that way you can always get back if stuff fails. Backups are just GZip compressed tar archives, so can be examined on a desktop PC to get specific files back via the add-ons above.

Fairly standard Linux command line commands for network tracing include:

ip a		# get i/f + addresses, can also set static addresses
ip r		# get routes
dig www.google.com
host www.google.com
traceroute www.google.com

Back to specifics:

  • is there anything silly I am missing here?
    I don’t know why the router didn’t start back up and offer HAOS a new DHCP lease and “just work”. Giving it 5minutes and unplug/replug the RPi4 LAN cable might fix a timing issue.
    Hopefully the tools above can show you more information as to what is failing.
    Worst case - pull the power to the RPi4 (shudder!). The file systems might not like the “dirty shutdown”, but it’s better than a wipe and restore backups.

  • should it be avoided to switch off my ISP router for a few days?
    Probably - less of an issue on fibre, but it’s a bad idea on ADSL/ VDSL/ DOCIS as the WAN interface gets “trained” based on the line noise.

If this helps, :heart: this post!

1 Like

Thanks both for your contributions!

I understand the timeout mechanism now, thanks for the explanation. It’s a shame not being able to unplug my router when I’m on holiday etc, as I feel it is a wasted power consumption.

Indeed my raspberry pi 4 is connected directly to the router.

I have done unplug/plug back in the ethernet cable on the Pi, waiting 5min in between, but no luck. I still get the Cannot connect error message. Same thing when I remove the Pi power cable and plug it back in.

Oh well, I get the feeling I’m in for a full rebuild command when I have the chance to move my TV closer to my Pi to use command lines…

Thanks again.

Oh wow I just tried a new combination I had apparently not done before and it worked!!
I switched off my Pi and unplugged the LAN cable. I left it like that for 5min. Switched the Pi back on. Waited another 5min then plugged the LAN cable back in.

And it’s back and running!
This means that even if I do have to turn off my router for days I do have a back up plan that works to get it back.

Once again for your answers which guided me to the solution.

And please immediately create a full backup, and download the resulting file locally (off the RPi4):

Open your Home Assistant instance and Back up your Home Assistant installation.

Click on the new backup in the file table, and hit the ... bottom right to find the Download option.

Future you will thank you!

If this helps, :heart: this post!

Thanks, just did it!