ESP32 WiFi reason 8: ASSOC_LEAVE

Reason 8 means the station is leaving the network. On the ESP32 that is most often your own firmware asking for it.

WIFI_REASON_ASSOC_LEAVE (8). Espressif's description: Deassociated due to leaving.

When the ESP32 reports it

From Espressif's table: when the access point sends it, and when the station is disconnected by esp_wifi_disconnect() "and other APIs". In Arduino that includes WiFi.disconnect().

The usual causes

If you did not ask for it, log every place your code touches WiFi, with a timestamp, and look at what ran just before the reason 8.

Where you see the number

In ESP-IDF, the WIFI_EVENT_STA_DISCONNECTED event carries it: ((wifi_event_sta_disconnected_t *) event_data)->reason. In Arduino, the ARDUINO_EVENT_WIFI_STA_DISCONNECTED event has it in info.wifi_sta_disconnected.reason, and WiFi.disconnectReasonName() turns it into a name. Log it every time: the reason is what separates a wrong password from a weak signal.

When it happens at a customer's site

On your desk you see the reason in the log. On a device behind someone else's router you only hear that it "goes offline sometimes". Pinscope keeps the device's logs and its WiFi signal over time, so you can see which reason it disconnected with and whether the signal was dropping before it did. Free for three devices. Remote logging.

Related errors: WiFi reason 2: AUTH_EXPIRE · WiFi reason 200: BEACON_TIMEOUT · WiFi reason 201: NO_AP_FOUND · WiFi disconnect reasons. All ESP32 errors: the list. Reason codes and their meaning from Espressif's Wi-Fi Driver guide and esp_wifi_types.h.

More