Skip to content

MQTT Client Error Codes

For devices connected via the MQTT protocol, the server's common error codes are explained as follows.

MQTT v3.1.1

MQTT v3.1.1 protocol has only 10 return codes. These return codes can represent little meaning, and the same return code value can have different meanings in different messages.

CONNACK Packet

There are only 6 return codes in the CONNECT packet. Only when the return code of the CONNACK packet sent back by the server is 0, the connection is successfully established.

ValueReturn codeDescription
00x00 Connection acceptedConnection accepted
10x01 Connection rejected for unsupported protocol versionThe server does not support the MQTT protocol requested by the client.
20x02 Connection rejected for rejected client IDThe client ID is the correct UTF-8 string, but is not allowed by the server
30x03 Connection rejected for unavailable serverNetwork connection has been established, but MQTT service is unavailable
40x04 Connection rejected for damaged username or passwordThe data in the username or password is in the wrong format
50x05 Connection rejected for unauthorizedClient connection is not authorized
6-255Reserved for future

SUBACK Packet

There are only 4 return codes in the SUBACK packet. Except that the return code 0x80 indicates failure, the other return codes indicate that the subscription is successful, and the three values 0, 1, 2 represent the maximum QoS value of the subscribed message.

ValueReturn codeDescription
00x00 successMaximum granted QoS 0 message
10x01 successMaximum granted QoS 1 message
20x02 successMaximum granted QoS 2 message
1280x80 FailureFailure

MQTT v5.0

The MQTT v5.0 protocol renames the return code to a reason code, adding a reason code to indicate more types of errors.

The following table is a list of reason codes that represent the value of the reason code and the control packet containing the reason code:

DecimalHexadecimalNamePacket
00x00SuccessCONNACK, PUBACK, PUBREC, PUBREL, PUBCOMP, UNSUBACK, AUTH
00x00Granted QoS 0SUBACK
10x01Granted QoS 1SUBACK
20x02Granted QoS 2SUBACK
40x04Disconnect with Will MessageDISCONNECT
160x10No matching subscribersPUBACK, PUBREC
170x11No subscription existedUNSUBACK
240x18Continue authenticationAUTH
250x19Re-authenticateAUTH
1280x80Unspecified errorCONNACK, PUBACK, PUBREC, SUBACK, UNSUBACK, DISCONNECT
1290x81Malformed PacketCONNACK, DISCONNECT
1300x82Protocol ErrorCONNACK, DISCONNECT
1310x83Implementation specific errorCONNACK, PUBACK, PUBREC, SUBACK, UNSUBACK, DISCONNECT
1320x84Unsupported Protocol VersionCONNACK
1330x85Client Identifier not validCONNACK
1340x86Bad User Name or PasswordCONNACK
1350x87Not authorizedCONNACK, PUBACK, PUBREC, SUBACK, UNSUBACK, DISCONNECT
1360x88Server unavailableCONNACK
1370x89Server busyCONNACK, DISCONNECT
1380x8ABannedCONNACK
1390x8BServer shutting downDISCONNECT
1400x8CBad authentication methodCONNACK, DISCONNECT
1410x8DKeep Alive timeoutDISCONNECT
1420x8ESession taken overDISCONNECT
1430x8FTopic Filter invalidSUBACK, UNSUBACK, DISCONNECT
1440x90Topic Name invalidCONNACK, PUBACK, PUBREC, DISCONNECT
1450x91Packet Identifier in usePUBACK, PUBREC, SUBACK, UNSUBACK
1460x92Packet Identifier not foundPUBREL, PUBCOMP
1470x93Receive Maximum exceededDISCONNECT
1480x94Topic Alias invalidDISCONNECT
1490x95Packet too largeCONNACK, DISCONNECT
1500x96Message rate too highDISCONNECT
1510x97Quota exceededCONNACK, PUBACK, PUBREC, SUBACK, DISCONNECT
1520x98Administrative actionDISCONNECT
1530x99Payload format invalidPUBACK, PUBREC, DISCONNECT
1540x9ARetain not supportedCONNACK, DISCONNECT
1550x9BQoS not supportedCONNACK, DISCONNECT
1560x9CUse another serverCONNACK, DISCONNECT
1570x9DServer movedCONNACK, DISCONNECT
1580x9EShared Subscription not supportedSUBACK, DISCONNECT
1590x9FConnection rate exceededCONNACK, DISCONNECT
1600xA0Maximum connect timeDISCONNECT
1610xA1Subscription Identifiers not supportedSUBACK, DISCONNECT
1620xA2Wildcard Subscription not supportedSUBACK, DISCONNECT

The reason code is a single-byte unsigned value used to indicate the result of the operation. The reason code less than 0x80 indicates that the result of the operation is successful. Under normal circumstances, the reason code value returned by the operation is 0. If the reason code returned is greater than or equal to 0x80, the operation has failed.

The reason codes for CONNACK, PUBACK, PUBREC, PUBREL, PUBCOMP, DISCONNECT and AUTH control packets are stored in the variable header. The SUBACK and UNSUBACK packets contain a list of reason codes in the payload.