The ESPHome dashboard uses mDNS to locate devices via .local. My dashboard was working fine with the six devices I have, however all of a sudden it showed all devices as offline.
At first I thought some changes I was making to my router and dns resulted in the ESPHome docker container not resolving mDNS requests - I could not ping .local from the container so this seemed to confirm it. This let me in the wrong direction - a better search would have shown that ESPHome uses aioesphomeapi which resolves the mDNS names internally without using the system resolver configuration.
Running the included aioesphomeapi-discover
utility resulted in an error message:
OSError: [Errno 105] No buffer space available
This led me to the following GitHub issue for ESPHome: github.com/esphome/issues/issues/2669 and the following, which increases whatever buffer the aioesphomeapi libraries relies on
sudo sysctl -w net.ipv4.igmp_max_memberships=50
echo net.ipv4.igmp_max_memberships = 50 | sudo tee -a /etc/sysctl.conf
I still have not worked out why this change was required - whether something else on the host OS was using more buffer space than before or if something else like a change to the default value occured. In any case a quick and easy fix and the ESPHome dashboard was able to resolve the devices via mDNS again.