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.

ReasonNameMeaning
1WIFI_REASON_UNSPECIFIEDUnspecified reason
2WIFI_REASON_AUTH_EXPIREAuthentication expired
3WIFI_REASON_AUTH_LEAVEDeauthentication due to leaving
4WIFI_REASON_DISASSOC_DUE_TO_INACTIVITYDisassociated due to inactivity
5WIFI_REASON_ASSOC_TOOMANYToo many associated stations
6WIFI_REASON_CLASS2_FRAME_FROM_NONAUTH_STAClass 2 frame received from nonauthenticated STA
7WIFI_REASON_CLASS3_FRAME_FROM_NONASSOC_STAClass 3 frame received from nonassociated STA
8WIFI_REASON_ASSOC_LEAVEDeassociated due to leaving
9WIFI_REASON_ASSOC_NOT_AUTHEDAssociation but not authenticated
10WIFI_REASON_DISASSOC_PWRCAP_BADDisassociated due to poor power capability
11WIFI_REASON_DISASSOC_SUPCHAN_BADDisassociated due to unsupported channel
12WIFI_REASON_BSS_TRANSITION_DISASSOCDisassociated due to BSS transition
13WIFI_REASON_IE_INVALIDInvalid Information Element (IE)
14WIFI_REASON_MIC_FAILUREMIC failure
15WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT4-way handshake timeout
16WIFI_REASON_GROUP_KEY_UPDATE_TIMEOUTGroup key update timeout
17WIFI_REASON_IE_IN_4WAY_DIFFERSIE differs in 4-way handshake
18WIFI_REASON_GROUP_CIPHER_INVALIDInvalid group cipher
19WIFI_REASON_PAIRWISE_CIPHER_INVALIDInvalid pairwise cipher
20WIFI_REASON_AKMP_INVALIDInvalid AKMP
21WIFI_REASON_UNSUPP_RSN_IE_VERSIONUnsupported RSN IE version
22WIFI_REASON_INVALID_RSN_IE_CAPInvalid RSN IE capabilities
23WIFI_REASON_802_1X_AUTH_FAILED802.1X authentication failed
24WIFI_REASON_CIPHER_SUITE_REJECTEDCipher suite rejected
25WIFI_REASON_TDLS_PEER_UNREACHABLETDLS peer unreachable
26WIFI_REASON_TDLS_UNSPECIFIEDTDLS unspecified
27WIFI_REASON_SSP_REQUESTED_DISASSOCSSP requested disassociation
28WIFI_REASON_NO_SSP_ROAMING_AGREEMENTNo SSP roaming agreement
29WIFI_REASON_BAD_CIPHER_OR_AKMBad cipher or AKM
30WIFI_REASON_NOT_AUTHORIZED_THIS_LOCATIONNot authorized in this location
31WIFI_REASON_SERVICE_CHANGE_PERCLUDES_TSService change precludes TS
32WIFI_REASON_UNSPECIFIED_QOSUnspecified QoS reason
33WIFI_REASON_NOT_ENOUGH_BANDWIDTHNot enough bandwidth
34WIFI_REASON_MISSING_ACKSMissing ACKs
35WIFI_REASON_EXCEEDED_TXOPExceeded TXOP
36WIFI_REASON_STA_LEAVINGStation leaving
37WIFI_REASON_END_BAEnd of Block Ack (BA)
38WIFI_REASON_UNKNOWN_BAUnknown Block Ack (BA)
39WIFI_REASON_TIMEOUTTimeout
46WIFI_REASON_PEER_INITIATEDPeer initiated disassociation
47WIFI_REASON_AP_INITIATEDAP initiated disassociation
48WIFI_REASON_INVALID_FT_ACTION_FRAME_COUNTInvalid FT action frame count
49WIFI_REASON_INVALID_PMKIDInvalid PMKID
50WIFI_REASON_INVALID_MDEInvalid MDE
51WIFI_REASON_INVALID_FTEInvalid FTE
67WIFI_REASON_TRANSMISSION_LINK_ESTABLISH_FAILEDTransmission link establishment failed
68WIFI_REASON_ALTERATIVE_CHANNEL_OCCUPIEDAlternative channel occupied
200WIFI_REASON_BEACON_TIMEOUTBeacon timeout
201WIFI_REASON_NO_AP_FOUNDNo AP found
202WIFI_REASON_AUTH_FAILAuthentication failed
203WIFI_REASON_ASSOC_FAILAssociation failed
204WIFI_REASON_HANDSHAKE_TIMEOUTHandshake timeout
205WIFI_REASON_CONNECTION_FAILConnection failed
206WIFI_REASON_AP_TSF_RESETAP TSF reset
207WIFI_REASON_ROAMINGRoaming
208WIFI_REASON_ASSOC_COMEBACK_TIME_TOO_LONGAssociation comeback time too long
209WIFI_REASON_SA_QUERY_TIMEOUTSA query timeout
210WIFI_REASON_NO_AP_FOUND_W_COMPATIBLE_SECURITYNo AP found with compatible security
211WIFI_REASON_NO_AP_FOUND_IN_AUTHMODE_THRESHOLDNo AP found in auth mode threshold
212WIFI_REASON_NO_AP_FOUND_IN_RSSI_THRESHOLDNo 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