known·good

Notes / esphomeesp8266nodemcuwifidhcpiot

ESPHome ESP8266 nodes stop joining Wi-Fi: reason='Association Leave'

· by shaun

ESPHome NodeMCU devices that had been working suddenly could not connect, logging lwIP error -16 and "Disconnected … reason='Association Leave'". The router's DHCP pool was full; giving the nodes static IPs fixed it.

Tested onESPHome (2021) on ESP8266 NodeMCU boards; consumer Wi-Fi router with a small DHCP pool

Symptoms #

ESPHome nodes that had worked for months stopped joining the network. The logs repeated:

text[I][wifi:194]: WiFi Connecting to 'xyz'...
[W][wifi_esp8266:191]: wifi_apply_hostname_(somehostname): lwIP error -16 on interface st (index 0)
[W][wifi_esp8266:395]: Event: Disconnected ssid='xyz' bssid=C8:0E:15:xx:xx:xx reason='Association Leave'

Cause #

The router's DHCP address pool was exhausted. The node associates, fails to get an address, and the connection is torn down with Association Leave, which looks like a Wi-Fi problem but is really an IP-addressing one.

Fix #

Either enlarge the DHCP pool or remove stale leases on the router, or give each node a static address outside the pool in its wifi: block:

yamlwifi:
  ssid: "xyz"
  password: "your-wifi-password"
  manual_ip:
    static_ip: 192.168.1.150
    gateway: 192.168.1.1
    subnet: 255.255.255.0

Pick an address outside the router's DHCP range so it can never be handed out twice.