MQTT Brokers and Cloud Hosting Guide


In order to use MQTT you require an MQTT broker.

The broker (server) is the central hub of an MQTT network as shown in the diagram below..

MQTT- Publish-Subscribe-Model

When it comes to choosing an MQTT broker you have three main options:

  • Use your Own Locally Installed Broker/Server
  • Use a Cloud Based Sever or Virtual Server
  • Use a Shared Server Application

Own Server Locally Installed

You can install an MQTT broker on your own server hardware including a raspberry Pi.

There are many brokers/servers to choose from, and most are free and open source.

Each of these brokers will have their own requirements e.g Aedes (formally Mosca) is a Node.js based and so requires node.js to be installed.

The table below lists the most popular brokers

Broker Description
Mosquitto Lightweight open source broker written in C. Probably the most popular MQTT broker. Supports MQTT v3.1.1 and v5

This is likely to be the default broker for edge networks.

See Introduction to the  Mosquitto broker.

Official Website Website

Install instructions Windows and Linux

Pro version available from cedalo which is the company developing mosquitto.

Includes self hosted and cloud hosting. See Pro Edition for Mosquitto MQTT Broker

Mosca- Now Aedes
Mosca now Aedes is Node.js based and so requires node.js to be installed.See GitHub

It can also be installed as a node in node-red.

Aedes Replaces Mosca and Mosca is no longer being developed.

It is not very feature rich when compared to mosquitto but ideal for home automation projects.

Currently supports v 3.1.1

Runs on Windows and LInux

See installing Aedes on node-red


Written in Erlang is Open Source and described as massively scalable.

EMQ Implements both MQTT V3.1 and V3.1.1 protocol specifications, and supports MQTT-SN, CoAP, WebSocket, STOMP . See Github

Python Test Broker Python test broker including MQTT v5
VerneMQ Written in Erlang and supporting clustering.
HiveMQ HiveMQ CE is a Java-based open source MQTT broker that fully supports MQTT 3.x and MQTT 5.

They also provide an enterprise ready broker See

and also a cloud version

and a public test broker



Note: Comprehensive comparison list on wiki

The problem with this arrangement is that you are responsible for the installation, and maintenance of the hardware and software.

This is likely to be the main choice for local MQTT applications and also ideal when testing or learning MQTT..

Mosquitto vs Mosca (now Aedes) for Learning and Testing

If you are just getting started with MQTT and you are also using node-red then you might want to use the Aedes broker.

Aedes/Mosca is a very simple broker and ideal for small home network deployments and for learning MQTT.

It is can be installed as a node-red node and then added to a flow.

Mosca (Aedes)  supports websockets and also  SSL.See Install Aedes Broker on Node-Red

However my test broker is mosquitto as it allows me to test all the different features of MQTT

Install Broker on a Virtual Server

These are available from many providers and are currently mainly used for website hosting.

However they can be used for hosting any web application, and will be a popular choice for hosting Node.js and MQTT in the cloud.

With this type of hosting you aren’t responsible for the hardware, but software install and management is your responsibility.

Online or cloud based MQTT servers/brokers are likely to be used for connecting different physical geographic locations together.

Google, Amazon, Microsoft, IBM and many others provide cloud based hosting.

Docker Installs

Many MQTT brokers are available as Docker images and using Docker is becoming a popular choice due to the flexibility.

See Running The Mosquitto MQTT Broker In Docker

Managed MQTT Servers/Brokers- Cloud Hosting

This is similar to cloud servers except you are limited to hosting a single application i.e MQTT.

This is very similar to the way present day websites are hosted.

This form of hosting is preferred for small organisations as the software install and maintenance is done by the hosting company.

Just as with standard web hosting there are likely to be a wide range of options available for MQTT hosting

Because the market is still very new there are very few dedicated commercial MQTT hosting providers.

Here are the ones I am currently aware of.

Cloudmqtt is offering production MQTT options all of the others are focused on testing. Unfortunately it no longer offers a free account .See Creating an MQTT Broker With CloudMQTT and this video

flespi is a new online broker offering free MQTT broker service and support MQTT v5. Currently there doesn’t appear to be a paid option. offers MQTT services and REST API support. It has lots of plans, including a free option, and also offers online message storage.

Beebotte -IOT Platform supports MQTT , Websckets and REST API. Provides a free tier for evaluation. – Shared or dedicated broker hosting.

Mosquitto Premium – The open source mosquitto broker but with added features like broker redundancy.

Online Test Brokers

These brokers  are used for testing MQTT but a view offer commercial packages.

 Online Cloud Base MQTT Brokers/Servers

Broker Type Broker Address and Port Websocket Support SSL support



Encrypted port 8081

Un-encrypted 8080

Yes 8883 With Client certificate 8884




Mosquitto  Yes

80 and 443 (SSL)





Benchmark Tests

Here are a few benchmark test results that you should find interesting.

In both case mosquitto came out wit the best performance, Mosca was surprisingly close.

Common Questions and Answers

Question – I have two locations do I need a broker in each location or should I use a cloud broker?

Answer – If you have only a few MQTT devices in each location then it would make sense to use a cloud based broker. If you have thousands then a local broker in each location would make more sense.

Question – Do I need to use SSL on my local broker?

Answer -If your network is private then I don’t think it is really necessary.

Question -Can I access my local broker from across the Internet?

Answer -Yes you can use port forwarding along with Dynamic DNS to make your broker available across the Internet.


All of the major cloud platform providers provide MQTT support and are likely to be the choice for enterprise organisations.

MQTT brokers as a service providers like cloudmqtt are likely to be the choice for smaller organisations that require MQTT between locations.

Almost all organisations are likely to deploy local brokers and the popular choice here is going to be mosquitto and for home automation I would think Aedes.

Both Aedes and mosquitto are small enough to run on very simple hardware like the raspberry PI.

Moving MQTT Providers

Because MQTT brokers don’t really store messages long term (unlike email) moving MQTT providers should be relatively easy.

Related Articles and resources:

Please rate? And use Comments to let me know more


  1. Hello Steve,
    great article – thanks for that.
    I have a question you might help me with:
    I’m using the hivemq cloud to publish some topics for water/gas/power consupmtion of my home.
    The topics will be send by ESP8266 devices. That works well normaly.
    But from time to time (4 weeks??) all topics have been deleted – only the ones that are published at this moment do create a topic – all other ones have been removed.
    Can you tell me what is happening here – I’m a bit confused.

    Thanks in advance

      1. Hi Steve,
        there is one main topics like /fw/gassensor/ on the MQTT broker. Underneath this topic you’ll find a few topics like gas_act_day, gas_act_day1, gas_act_day2 which have the gas consumption for the last past days.
        So the structure is /fw/gassensor/gas_act_day1, /fw/gassensor/gas_act_day2 a.s.o.
        From time to time the topics gas_act_day1 to n disappeare – these topics are only published once a day during the night – all with retain flag. What stays is the structure /fw/gassensor/, but only because there are other topics within this structure which are published one a minute (heartbeat topic, to see if my ESP8266 is still alive).
        In my opinion the adminitrator of the broker must run a script that deletes all topics – do you of that?? It’s the free version of HIVEMQ.

        1. Frank
          They could either reboot the server or delete all retained messages.
          The topic structure itself isn’t really important it is the retained messages which I assume are deleted.
          You might want to try

          1. Hi Steve,
            that might be the reason – thanks
            Any idea how to avoid this ??
            Hivemq works perfectly for me – except for this.
            And this let’s me lose all my historical data like consumption for the last few months, which I store in different topics (…._jan, ….feb). All gone after deletion.

          2. Frank
            Using the retain feature is not a reliable way of storing data.You really need to pull it into a program and store it to a file or database.

  2. Hi Steve,

    Thanks for the article! I have a question and was hoping you could help me out with them.

    We are designing a fleet management system and one of the criteria is to handle offline and online modes as there might be no internet connectivity in certain areas (dead spots).

    Do we need both local and cloud MQTT brokers for communication and data transfer purposes when the internet connectivity comes back online? In other words, the data should be stored in a local database when there is no connectivity and should automatically synchronize to the cloud when the internet connectivity comes back online. How can we achieve that?

    Thanks for the pointers.

  3. Hi Steve,

    Excellent article! I have a couple of questions that I was hoping you could help me out with.

    1. I need a cloud based MQTT broker for my IOT application. I need access to the MQTT topics remotely. Is there a way to set up this virtual/cloud broker and use it for free? I noticed that Message frequency and Payload is very less. I wish to offer this solution to a customer for a fixed price and not ask them for a monthly payment for the maintenance or usage of the cloud service? Do you think there are such options available?

    2. I have used the Hive free broker and it works pretty well for me. Would you recommend the free brokers for commercial use?

    3. Do you have any recommendations for simple tools to create web applications to visualize this mqtt data?

    1. There is beebotte
      and I’m sure that there are lots of others.All are limited in some way.
      I wouldn’t recommend using a test broker for commercial use on a permanent basis.
      What do you mean exactly by visualise data?

      1. Oh looks like beebotte is just what I’m looking for. Thank you for the recommendation.

        By visualizing data I mean plotting graphs and creating dashboards on a web application that can be accessed from any device using a browser. Looks like beebotte has dashboard service as well. I can explore that option.
        Thanks again!

  4. Hello Mr. Steve,
    As your article that according to your e-book mention that there are three main options for MQTT broker.
    I am wondering about the shared server application type, for example I have tried to use myqtthub to do some testing about MQTT protocol, Should I identify this as Shared Server Application or Cloud Based Server type.


      1. Hello Mr. Steve,
        Thank you for your answer.
        For shared server application type, Do you have some examples of it? so that I can understand it more clearly.


          1. Hello Mr. Steve,
            I very appreciate for your quick answer to my questions.
            Thank you

  5. Hi Steve,

    Thanks for this article!

    It would be awesome if you add Stackhero to the MQTT managed cloud providers:

    It runs Mosquitto on dedicated VM, with generous simultaneous connections, TLS encryption (MQTTS), user authentication and can be plugged to an API to handle authentication for thousands of devices.

    You can contact me if you want more informations about it. Or you can test it for free on Stackhero website 🙂


    1. it looks to me that
      client = new Paho.MQTT.Client(location.hostname, Number(location.port), “clientId”);
      client = new Paho.MQTT.Client(localhost, 1883, “testclient”);

  6. Hi, Steve. I want to publish data from my Arduino to the broker. I’m planning to publish that data to the phpmyadmin of the website, so I can monitor the data from anywhere. What is the better choice of MQTT broker for me? Is that cloud-based server is the better choice?
    if I install broker locally on my computer, I have an IP address that same with localhost of phpmyadmin, so then i can publish data to broker and phpmyadmin. But actually, i can be monitor in the same area. I can’t access that data anywhere.

      1. Actually, i think the broker can communicate with phpmyadmin (DBMS) with rest API through creating a web service. I dont have the link that explain how MQTT can publish to phpmyadmin, but I want to communicate them and creat an Iot device. I knew about the use of rest API in this link

        1. If you want to access the published data from anywhere then you need a cloud based broker or port forward a local broker. As for the PHPmyadmin I can’t offer any help as I don’t use it.

  7. I have created a aws ec2 linux machine….There i install mosquitto broker…As python subscriber and publisher from my pc, how can i connect to this linux machine???

    1. Hi
      It should have a domain name or ip address. I don’t know where to locate it as I don’t use AWS.

  8. Dear Steve,
    I would like to read the data from a sensor with mqtt and then sending that data to an already existing web server. My question is, how can I send the data from the mqtt broker to the server? Because I think that servers use http… And what is the best mqtt broker I could use for that

    1. Hi
      It is difficult to get data to a web server unless the server allows you to post the data. If it does then you need to use http to post the value.

  9. Due to some reason, I want to create my own broker (not using Moquitto or HiveMq). I could not find documentation/SDKs that should use for this purpose. Can you please guide me?

  10. I’m looking to set up an MQTT broker server – either Ubuntu or CentOS. I want to store the IoT data in a (possibly MySQL) DB so that I can then develop some code to write parts of the stored IoT data into a third party API. Exactly what are the best tools I can use to do this?

  11. Hi Steve,
    I was using the aws Iot core as my broker but then i found out that it does not support retained messages.
    What broker would you recommend that is highly scalable and supports retained messages. It could be menaged / not menaged.

    thank you.

  12. Hello Steve,
    I want to send/publish my sensors data to mqtt broker and then save this mqtt data into a database. So I need a server which is able to act as a mqtt broker and capable to save the mqtt data into database 24×7. Which server can I use to serve these both purpose?


    1. Mosquitto doesn’t do this but maybe a commercial on like HiveMQ will. However a better way I feel is to use a client to subscribe to those topics and log the data to the database.
      That is the big advantage of the MQTT protocol is that it is effectively broadcast by default.

      1. Hi,
        Yes I am going to use a client (paho mqtt client) to subscribe to the topics and then log the data to the database. I will be running the python script to subscribe to the topic and then store the data in database. But I will run these python script on a server.
        So can I use the same server as mqtt broker and as the database server? And is it possible to use Virtual server for both the purposes?

  13. hi Steve,
    I’m using mosquitto and node-red with PC as my local host.
    My question is can i create a data base for particular number of users?

  14. Dear Steve,
    You are posting very interesting stuff. Thanks for that.
    I have configured a ubuntu Linux PC (as this is completely new to me) with node-red and mosquitto. So far on this PC I can use local mqtt communication.
    Now I want to connect a windows 10 PC to connect with a home network to that Linux PC addressing mosquitto (port 1883).
    I set up the edit mqtt-broker node as:
    Name: Mosquitto srv
    Connection: port 1883 (ping works)
    Empty client ID
    Security: Name and password for Linux login

    Now i configure a mqtt-out node (topic first/one) with a timestamp node as input trigger: Node-Red screen shows below mqtt node – disconnected to connecting but not connected ….
    Can you help me with this. I guess this can help more people as I could not fine any solotion yet on the internet.
    Thanks in advance.

    1. Hi
      The connect disconnect issue occurs when two clients use the same client id.On the node don’t configure a client is it will create a random one and see if that works.

    2. Hi Steve,
      With our input and your YouTube serie “MQTT Publish an Subsrcibe Using Node Red” I was able to solve the issue.
      rgds Dirk-Jan

  15. In the category of “online test brokers”, I am using Cayenne ( for broker (they supply the service) and I use their API for client; it’s a good API, but intended only for connecting to Cayenne. There is currently no charge, at least for light usage. I also found out how to use paho.mqtt.client instead of Cayenne client software. They provide a nice dashboard for web browsers and a smartphone app.

  16. hi sir
    I have make an program for DS18b20 sensor, it’s running when i operation by REPL to using “import main” command, but when i remove USB cable from my PC and plug in it into USB mobile charger (2amp charger) that time code stop at “Client.connect()” line and not connecting to my mqtt server

    what should i have to add in my code pls suggest me

    please help me regarding this

    code are bellow

    import onewire, ds18x20, time, network, machine
    from umqtt.simple import MQTTClient

    ds_pin = machine.Pin(15)
    led1= machine.Pin(2, machine.Pin.OUT)

    ds_sensor = ds18x20.DS18X20(onewire.OneWire(ds_pin))

    roms = ds_sensor.scan()

    print(‘Found DS devices: ‘, roms)

    SERVER = ‘’
    CLIENT_ID = ‘ESP32′

    TOPIC = b’temp’

    client = MQTTClient(CLIENT_ID, SERVER)



    while True:



    for rom in roms:



    t = ds_sensor.read_temp(rom)

    msg = (b'{0:3.1f}’.format(t))

    client.publish(TOPIC, msg)







    1. Hi
      Sorry but never used the DS18b20 sensor.I gather that it is arduino which I’m not a big user of and don’t know how to use it with Python.
      I have a feeling that it needs to be plugged into the PC as that is the way the python code is working but I don’t know for sure.

  17. Hello Steve,
    Could be a silly question but does MQTT support image payload? If yes any headsup which MQTT broker/client supports images? Any experience would you like to share with me


  18. Dear Steve,

    I have the broker, I want to connect to this server using MQTT command.


    AT+CMQTTCONNECT this command requires the TCP. I don’t what is the TCP server address.

  19. Using Eclipse Mosquitto, how can I run an application? I wanted to check the performance like the update time between publisher and subscriber. How do I do that?

Leave a Reply

Your email address will not be published. Required fields are marked *