Skip to content

How to fix Mqtt error: Connection refused: Not authorised? 

  • by
  • 3 min read

As fun as working with hardware is, it can also sometimes be a major hassle when things don’t work as intended. Anything from a slight logic error in your code to an improper hardware connection can cause problems. 

In this article, we’re talking about the “MQTT error: Connection refused: Not authorised” issue, its causes and what you can do to fix the problem.


What causes the Mqtt error?

As you can probably guess by the error name itself, it’s caused by authentication failures when connecting to a secure database or service. Possible reasons include:

  • Using incorrect credentials. 
  • Misconfigured package files. 
  • App ID or privacy key isn’t correct. 

Also read: How to fix Web page stuck in mobile view error?


How to fix this?

Here are five fixes you can try out. 

Check the credentials

The first thing you should do is check to see if the credentials you’re using are correct. Make sure the case matches the one you used when creating them. If you’re using these in a command line argument, check the documentation to see if you need to write any flags or any other specific formatting that’s required for the command to parse these properly. 


Restart your router

Power cycling your network equipment is the fix to more issues than you can think. More often than not, connectivity issues can be caused by an underlying bug in your router and can be fixed by rebooting.

Countries with highest internet download speeds ranked (july)

Check the app ID and key

Similar to credentials, some MQTT apps require a specific app ID and key per app that you try to register or use with a database or service. This is done so the server can tell different apps from one another and not mix up data. Check to make sure you’re using the right app ID and key and in the right format. 


Reinstall any recent libraries

If the error started showing up after you added or installed any libraries, check to make sure they’re properly installed and that they aren’t interfering with the authentication process. Alternatively, uninstall the library and try connecting again to see if your app still works. If it does, chances are that the error was in the library you downloaded and a reinstall should fix the issue. 

What is metadata? Types and benefits | candid. Technology
Photo by shahadat shemul

Update your configuration files

Libraries like Zigbee often require dedicated configuration files where you save your server URL and credentials. Check to see if the file actually exists and is made as per the documentation suggests.

Also read: How to fix Epson 8550 repeated paper jam error?

Yadullah Abidi

Yadullah Abidi

Yadullah is a Computer Science graduate who writes/edits/shoots/codes all things cybersecurity, gaming, and tech hardware. When he's not, he streams himself racing virtual cars. He's been writing and reporting on tech and cybersecurity with websites like Candid.Technology and MakeUseOf since 2018. You can contact him here: yadullahabidi@pm.me.

>