Help with esphome error/rebooting every 2-3 hours


I’m getting my esp8285 device rebooting itself every 2-3 hours. I have confirmed this with an uptime.sensor, and i have set the reboot_timeout for API and wifi to 9999 to ensure they are not contributing.

I notice in the esphome logs i get the following error once per minute:

[21:23:24][W][api.connection:071]: Socket operation failed: BAD_INDICATOR errno=11

I have seen this same problem reported by another user on github, their solution was to restart HA and this resolved the issue: Socket operation failed: BAD_INDICATOR errno=11 After updating to 2023.2.3 · Issue #4223 · esphome/issues · GitHub

also it is reported here as a memory leak, makes sense as they build up eventually the device runs out of memory and reboots: Memory leak on ESP8266 when using api encryption after socket error · Issue #3320 · esphome/issues · GitHub

Naturally I have tried this but to no success.

I have also tried

  • completely removing the device from HA integrations and re-adding,
  • completely removing the device from ESPhome and re-adding
  • renaming the device
  • I have an identical device that does NOT have this problem, even when loaded with the exact same config

For additional reference, her is the corresponding error from HA.

2023-05-31 21:21:23.930 INFO (MainThread) [aioesphomeapi.connection] Error while reading incoming messages: Connection requires encryption

if anyone has any solutions to try I would appriciate if you would share them with me

P.S. Aside from the 2-3 hourly boot, there appears to be no other negative effect. the device shows up in HA and responds correctly at all times unlike some others had reported.


If anyone else has this issue, it seems to be something to do with HA trying to connect with an “old” esphome configuration that isn’t there anymore at a specific IP. HA is trying to connect to a device at the same address, pinging an error which is logged on the device but isn’t handled well by the esphome device leading to a memory leak, which fills the memory leading to a crash

you can fix this by manually assigning an IP to the device. I have no idea how to get HA to “forget” the original device. any other device that gets DHCP’d to this address will end up with the same problem.

You should open an issue on Github. :+1:

I have the exact same issue with an ESP32.
Every 4h (third of the DHCP lease time from openwrt) it reboots (without any hints in the debug log of the esphome device).

I think there is an issue with the DHCP implementation in esphome on ESP32 devices, see here: ESP32 loses connection after exactly 3 hours and 20 minutes · Issue #1196 · esphome/issues · GitHub

After finding all this info, i will now try to set an manuall ip on the device and seehow it goes…

Setting an static ip did not solve the issue. I am out of ideas…
As a workaround i have setup all switches to retain state after a reboot an minimized reboot delay.

What is the reset_reason?

The reset_reaseon was “PowerOnReset”.
Also changed power supply, but the issue persists.

You are not using a bootstrapping/reset pin for any peripheral by any chance?

Best would be anyway to make a new thread about your problem (this one here is marked as solved by the author) and maybe peek in how to ask a good question (providing your yaml etc.)


Maybe :slight_smile:
It’s an Ulanzi TC0001 clock (pre built device).
GPIO15 is used by them for the buzzer, so it should not be an issue.

But i have changed something i teh yaml, if the issue is still present, i will open up an new thread.


1 Like

FYI not sure if you are aware, the reason for setting a static IP is to set it to something that hasn’t been used for ESPhome before. I don’t understand why, but i believe in the background something is going on that doesn’t let ESPhome “forget” old DHCP addresses sometimes, so you need to make sure you set it to something brand new (i did it to outside my DHCP) that definitely isn’t conflicting with any other reservations you have

thx for the hint. Now given the device an static IP outside my DHCP range and issue is not gone.
I think in my case, the reason is something else.
Will dive deeper into this when i find time.

I had a similar problem. In my case also some ( not all) devices reset periodically. Some every 2-3 hours or so others after 4-5. The software version I used and still use is 2023.10.4 . The problems started when I changed the authorization to the API from password to key. The devices that handled my lighting simply reset, which was quite annoying, especially for my wife ;). After reading this thread, I restored the authorization after the password and the problems ended. However, something tempted me and I upgraded the ESPHome version to 2023.12.5, which caused the problems to return. I restored version 2023.10.4 and have peace of mind for now. As proof, I paste a screenshot of the uptime history. where you can clearly see the configuration changes ( password key ) and the version upgrade.

Sorry to refresh the thread, but maybe someone has similar problems and my explanations will help them. I will add that I have problems on one wemos to which are connected relays that turn on the light. In addition, I have three sonoffs that also restart. The interesting thing is the fourth sonoff, which has the same ( except IP ) configuration and it does not restart.