ESP32 WiFi disconnect reasons
The number in WIFI_EVENT_STA_DISCONNECTED, every one of them. Codes below 200 come from the IEEE 802.11 standard; 200 and up are Espressif's own.
The ones that come up most: 201 (network not found), 15 and 204 (handshake timeout, often the password), 200 (lost the access point), 202, 210, 2 and 8.
| Reason | Name | Meaning |
|---|---|---|
| 1 | WIFI_REASON_UNSPECIFIED | Unspecified reason |
| 2 | WIFI_REASON_AUTH_EXPIRE | Authentication expired |
| 3 | WIFI_REASON_AUTH_LEAVE | Deauthentication due to leaving |
| 4 | WIFI_REASON_DISASSOC_DUE_TO_INACTIVITY | Disassociated due to inactivity |
| 5 | WIFI_REASON_ASSOC_TOOMANY | Too many associated stations |
| 6 | WIFI_REASON_CLASS2_FRAME_FROM_NONAUTH_STA | Class 2 frame received from nonauthenticated STA |
| 7 | WIFI_REASON_CLASS3_FRAME_FROM_NONASSOC_STA | Class 3 frame received from nonassociated STA |
| 8 | WIFI_REASON_ASSOC_LEAVE | Deassociated due to leaving |
| 9 | WIFI_REASON_ASSOC_NOT_AUTHED | Association but not authenticated |
| 10 | WIFI_REASON_DISASSOC_PWRCAP_BAD | Disassociated due to poor power capability |
| 11 | WIFI_REASON_DISASSOC_SUPCHAN_BAD | Disassociated due to unsupported channel |
| 12 | WIFI_REASON_BSS_TRANSITION_DISASSOC | Disassociated due to BSS transition |
| 13 | WIFI_REASON_IE_INVALID | Invalid Information Element (IE) |
| 14 | WIFI_REASON_MIC_FAILURE | MIC failure |
| 15 | WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT | 4-way handshake timeout |
| 16 | WIFI_REASON_GROUP_KEY_UPDATE_TIMEOUT | Group key update timeout |
| 17 | WIFI_REASON_IE_IN_4WAY_DIFFERS | IE differs in 4-way handshake |
| 18 | WIFI_REASON_GROUP_CIPHER_INVALID | Invalid group cipher |
| 19 | WIFI_REASON_PAIRWISE_CIPHER_INVALID | Invalid pairwise cipher |
| 20 | WIFI_REASON_AKMP_INVALID | Invalid AKMP |
| 21 | WIFI_REASON_UNSUPP_RSN_IE_VERSION | Unsupported RSN IE version |
| 22 | WIFI_REASON_INVALID_RSN_IE_CAP | Invalid RSN IE capabilities |
| 23 | WIFI_REASON_802_1X_AUTH_FAILED | 802.1X authentication failed |
| 24 | WIFI_REASON_CIPHER_SUITE_REJECTED | Cipher suite rejected |
| 25 | WIFI_REASON_TDLS_PEER_UNREACHABLE | TDLS peer unreachable |
| 26 | WIFI_REASON_TDLS_UNSPECIFIED | TDLS unspecified |
| 27 | WIFI_REASON_SSP_REQUESTED_DISASSOC | SSP requested disassociation |
| 28 | WIFI_REASON_NO_SSP_ROAMING_AGREEMENT | No SSP roaming agreement |
| 29 | WIFI_REASON_BAD_CIPHER_OR_AKM | Bad cipher or AKM |
| 30 | WIFI_REASON_NOT_AUTHORIZED_THIS_LOCATION | Not authorized in this location |
| 31 | WIFI_REASON_SERVICE_CHANGE_PERCLUDES_TS | Service change precludes TS |
| 32 | WIFI_REASON_UNSPECIFIED_QOS | Unspecified QoS reason |
| 33 | WIFI_REASON_NOT_ENOUGH_BANDWIDTH | Not enough bandwidth |
| 34 | WIFI_REASON_MISSING_ACKS | Missing ACKs |
| 35 | WIFI_REASON_EXCEEDED_TXOP | Exceeded TXOP |
| 36 | WIFI_REASON_STA_LEAVING | Station leaving |
| 37 | WIFI_REASON_END_BA | End of Block Ack (BA) |
| 38 | WIFI_REASON_UNKNOWN_BA | Unknown Block Ack (BA) |
| 39 | WIFI_REASON_TIMEOUT | Timeout |
| 46 | WIFI_REASON_PEER_INITIATED | Peer initiated disassociation |
| 47 | WIFI_REASON_AP_INITIATED | AP initiated disassociation |
| 48 | WIFI_REASON_INVALID_FT_ACTION_FRAME_COUNT | Invalid FT action frame count |
| 49 | WIFI_REASON_INVALID_PMKID | Invalid PMKID |
| 50 | WIFI_REASON_INVALID_MDE | Invalid MDE |
| 51 | WIFI_REASON_INVALID_FTE | Invalid FTE |
| 67 | WIFI_REASON_TRANSMISSION_LINK_ESTABLISH_FAILED | Transmission link establishment failed |
| 68 | WIFI_REASON_ALTERATIVE_CHANNEL_OCCUPIED | Alternative channel occupied |
| 200 | WIFI_REASON_BEACON_TIMEOUT | Beacon timeout |
| 201 | WIFI_REASON_NO_AP_FOUND | No AP found |
| 202 | WIFI_REASON_AUTH_FAIL | Authentication failed |
| 203 | WIFI_REASON_ASSOC_FAIL | Association failed |
| 204 | WIFI_REASON_HANDSHAKE_TIMEOUT | Handshake timeout |
| 205 | WIFI_REASON_CONNECTION_FAIL | Connection failed |
| 206 | WIFI_REASON_AP_TSF_RESET | AP TSF reset |
| 207 | WIFI_REASON_ROAMING | Roaming |
| 208 | WIFI_REASON_ASSOC_COMEBACK_TIME_TOO_LONG | Association comeback time too long |
| 209 | WIFI_REASON_SA_QUERY_TIMEOUT | SA query timeout |
| 210 | WIFI_REASON_NO_AP_FOUND_W_COMPATIBLE_SECURITY | No AP found with compatible security |
| 211 | WIFI_REASON_NO_AP_FOUND_IN_AUTHMODE_THRESHOLD | No AP found in auth mode threshold |
| 212 | WIFI_REASON_NO_AP_FOUND_IN_RSSI_THRESHOLD | No AP found in RSSI threshold |
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 201: NO_AP_FOUND · WiFi reason 15 / 204: handshake timeout · esp_err_t codes. All ESP32 errors: the list. All reasons from ESP-IDF 5.5.3's esp_wifi_types.h; meanings from Espressif's Wi-Fi Driver guide.
More
- Remote access to an ESP32 without TLS: what it measured and what it costs
- Reaching an ESP32 web server from outside its network
- Updating ESP32 firmware over the internet, with rollback
- Guru Meditation Error: decoding the backtrace, and crashes from the field
- Remote logging: ESP_LOG without a serial cable
- Heap and stack monitoring in the field
- An ESP32 behind CGNAT, 4G or Starlink
- TLS memory usage on the ESP32, and how to reduce it
- Sharing an ESP32 sensor page with anyone, without port forwarding
- ArduinoOTA over the internet, with a rollback
- ESP32 remote access compared: port forwarding, ngrok, Cloudflare Tunnel, Tailscale
- esp_http_server slow? The 250 ms delay and the fix
- Before the first ESP32 ships: a field support checklist
- ESP32 exception decoder: a Guru Meditation backtrace to lines, in the browser