MQTT: Connection refused: unacceptable protocol version / identifier rejected
The broker does not accept the protocol version or client ID the client offered.
Exact message you may see
unacceptable protocol versionMQTT identifier rejectedConnection refused: bad protocol
Seen on:
MQTT
Meaning
Return code 1 is "unacceptable protocol version" (client speaks MQTT 5 to a 3.1 broker, or the reverse), and code 2 "identifier rejected" (bad or duplicate client ID).
Common causes
- Client uses MQTT 5 against an MQTT 3.1.1-only broker
- Empty or too long client ID
- Duplicate client ID kicks the older connection
- TLS port used for plain MQTT
⚡ Quick fix
- Set the protocol version explicitly
- Use a unique, valid client ID
- Match ports (1883 plain, 8883 TLS)
Detailed fix by platform
Python paho
mqtt.Client(client_id="dev-1", protocol=mqtt.MQTTv311)
How to diagnose
- Version — Both sides?
- ID — Unique and valid?
- Port — Plain or TLS?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Most viewed in API
Other ways to find it
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Did this fix work for you?
Report a correction or suggest an improvement
Last updated 2 Dec 2026