Suddenly unable to connect to Raspberry Pi running HA

My HA is running on Raspberry Pi 3 and it connects to my home network via ethernet.

Right now, I am running HA 0.65.6.

I faced this problem few times for the past few weeks.

The network connection to my HA suddenly fail after running for 1-2 days. I still can see the HA IP address in my DHCP server in my router. I assume it still connects to my network. But I couldn’t log into the HA frontend, SSH nor FTP. It seems connection to the RPi is lost. I have to manually turn off and on the power to make it running again.

Because of that, I am unable to access to the log. Any idea what happen or advice on how to troubleshoot this?

It’s probably an SD-Card or Power. My bet is on SD-Card. I had the same where HA effectively locks up every day or so - can’t access ssh etc. A better quality card will probably fix it.

1 Like

I got my share of that :slight_smile:
To be sure, I usually double check by hooking the RPi to a monitor to see the boot process or absolutely nothing.

1 Like

Thanks for your suggestion. For the past 2 years I have been using HA, I have changed 3 or 4 SD cards. If this is really caused by SD card, I think RPi is not ideal for running HA reliably. I haven’t tried running it on other mini computer with attached storage. I’m wondering do people who runs HA on such mini computer, do you face such problem?

Good idea. Will hook it up to a monitor. Thanks.

I just gone through a discussion about RPi alternatives for this same reason. Suggestions ranged from mini-pc/laptop/thin-client, I’m now testing the suggestion to move the db and log files off the main system SD card to another USB storage to save wear-n-tear on the main.
But @DavidFW1960 point about quality SD card and power supply is true too.
Also, you can pull the SD card out and check on another machine, linux works best.
May the force be with you.

I had an SD card causing the exact problem. When I later put it in my pc and re-formatted, it passed a HW test with flying colours. So weird.

But since changing that card I have not had a SINGLE incident with these problems.

I think I will create an automation to reboot the Pi on connection lost. Hopefully this will solve the problem…

##########################################################
# Binary Sensor
##########################################################
binary_sensor:
  - platform: ping
    name: Router
    host: 192.168.1.1
    count: 2
    scan_interval: 30

##########################################################
# Automation
##########################################################
automation:
  alias: 'Reboot Pi on Connection Lost'
  initial_state: on
  trigger:
    platform: state
    entity_id: binary_sensor.router
    to: 'off'
    for:
      minutes: 1
  action:
    - service: shell_command.reboot_pi

Will monitor this for 1 week and report the result.

I did face it once, but it was not related to SD card as I boot and run my RPi3 off an USB stick. In my case, I had networking messed up. With recent Raspbian the /etc/network/interfaces file is rather empty, while in the past it contained definitions for every interface in use. Now, it’s all up to automation via DHCP.

As a I result, I had a weird routing on that Raspberry Pi and from time to time the IPv4 routes dropped and only IPv6 still worked.

Check your routing using $ /sbin/route -n . It should only contain a default route (0.0.0.0) and one for your local network (mine ist 192.168.33.0/24).

$ /sbin/route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.33.1    0.0.0.0         UG    202    0        0 eth0
192.168.33.0    0.0.0.0         255.255.255.0   U     202    0        0 eth0

Normally, network problems are logged in /var/log/syslog, which is persistent. Were there any errors there?

I had the same problem when I was using Wifi on my Pi. Since I switched to wired it hasn’t happened.

thanks for your guide. this is what i have…

$ /sbin/route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    202    0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     202    0        0 eth0

Thanks for pointing that out. It seems a lot of things happened moments before it went down. Not sure what to look for. Anymore pointers?

OK thanks. I was using both Wifi and ethernet. I have removed Wifi connection as per your advice. Will monitor for few days and see how.

When removing the Wifi connection, keep in mind that there are several partitions on your SD card, only one of which is visible if you’re using Windows. If you only remove your SSID and password from that partition your credentials will still be saved. I’m not sure exactly what the behaviour is if you have an ethernet cable plugged in at the same time, but I had to purge it completely to be sure.

I added WiFi connection via…

  1. sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
  2. Add the following text to the end of the file…
network={
ssid="XXXXX"
psk="PASSWORD"
}

I assume if I remove that lines, it will undo the WiFi. Am I right?

I tried the route -n also and got 2 pairs of wlan and eth0 Destinations, I use wired connection as @masterkenobi, how to I disable the wlan?
RPi3 raspi-config shows there was no wireless SSID entered.

That’s what I mean - I don’t remember the partition names, but there are four partitions that are created on the SD card, and once you supply your Wifi details it copies them to a separate drive that won’t be visible in Windows (by default, unless you have an ext4 plugin). You have to delete it from that partition too in order to make it completely forget.

1 Like

I found this, basically disable the wifi/bt driver loading rather than mess with the partitions :slight_smile:

Disable Pi3 wifi and bluetooth

1 Like

That works too :slight_smile: but just to clarify it’s not actually messing with partitions, just editing text files on those partitions.

OK guys. It happened again.

My automation didn’t work.

I have disabled the Wifi connection and only using ethernet.

Scratching my head for other solution before changing to new SD card.

Was there anything in /var/log/syslog that might indicate the problem?