Member-only story
Run Mosquitto MQTT broker easily with docker
MQTT (Message Queuing Telemetry Transport) is a lightweight messaging protocol designed for simple, fast, and efficient communication between devices, especially in situations where network bandwidth and power resources are limited. MQTT is commonly used for IoT devices due to its lightweight nature. Additionally, we can use MQTT to add real-time capabilities to our applications, as it can be a substitute for WebSocket, particularly when our app runs on mobile devices.
One of the most popular MQTT brokers is Mosquitto. The Mosquitto MQTT broker has the capability to connect via WebSocket, allowing it to support web application clients running in a browser. In this guide, I will explain how to set up the Mosquitto broker using Docker, making it easy to run on your local machine or VPS server.
Docker Run
The simplest way to run the Mosquitto MQTT broker is by using docker run. Before that, let's create a configuration file. In the terminal, navigate to the folder where you want to save the config file, and run:
touch mosquitto.confThis will create an empty mosquitto.conf file. For now, add a basic configuration for local setup; we’ll add more complex settings later. Paste the following script into the mosquitto.conf file:

![Self Hosting WA api with whatsapp-web.js [PART 1]](https://miro.medium.com/v2/resize:fit:1358/format:webp/1*X7Oy69qYKdhI8KpzVZpmmQ.png)


![Self Hosting WA api with whatsapp-web.js [PART 2]](https://miro.medium.com/v2/resize:fit:1358/format:webp/1*GzdhGuivGjPIyvBIdp5VjQ.png)





