Tools: Installing Mosquitto on Mac and Raspberry Pi (2026)

Tools: Installing Mosquitto on Mac and Raspberry Pi (2026)

Introduction

Installing Mosquitto

For Mac

For Raspberry Pi

Starting the Broker

For Mac

For Raspberry Pi

Testing

Conclusion I needed to use MQTT for work and researched Mosquitto, which allows easy handling of MQTT. Although many have already documented Mosquitto installation, the methods differ slightly between Mac and Raspberry Pi, leading to some confusion. This article serves as my personal reference. Note that I won't delve into what MQTT is—please look it up if needed. You can install it using Homebrew. The software is installed in the following paths: Be sure to add these paths to your environment variable Path. For Raspberry Pi or Linux, you can install Mosquitto with the following commands: The broker acts as a server that mediates MQTT communication. Typically, cloud services like AWS IoT are used, but for testing purposes, we will start the broker on either Mac or Raspberry Pi. You only need one broker running, so there's no need to start both simultaneously. Also, note the IP address of the broker terminal for the next testing step. Start Mosquitto's broker with the following command: Start Mosquitto's broker with the following command: When you install Mosquitto using the steps above, it also installs simple clients for subscribing and publishing. We will use these clients for testing. Here’s the setup: Open the terminal on the subscription terminal and subscribe to the topic with the command below. The subscription terminal can be on the same device as the broker. Open the terminal on the publishing terminal and publish a message to the topic with the command below. Again, the publishing terminal can be the same as the broker terminal. If the message 'Hello' appears on the subscription terminal, the test is successful. Using Mosquitto, we can easily set up an MQTT environment for testing. Templates let you quickly answer FAQs or store snippets for re-use. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse

Command

Copy

$ -weight: 500;">brew -weight: 500;">install mosquitto -weight: 500;">brew -weight: 500;">install mosquitto -weight: 500;">brew -weight: 500;">install mosquitto # Install Mosquitto (Broker). -weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">install mosquitto # Install Mosquitto clients. -weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">install mosquitto-clients # Install Mosquitto (Broker). -weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">install mosquitto # Install Mosquitto clients. -weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">install mosquitto-clients # Install Mosquitto (Broker). -weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">install mosquitto # Install Mosquitto clients. -weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">install mosquitto-clients -weight: 600;">sudo -weight: 500;">service mosquitto -weight: 500;">status -weight: 600;">sudo -weight: 500;">service mosquitto -weight: 500;">status -weight: 600;">sudo -weight: 500;">service mosquitto -weight: 500;">status mosquitto_sub -h 192.168.11.18 -t tp1/test mosquitto_sub -h 192.168.11.18 -t tp1/test mosquitto_sub -h 192.168.11.18 -t tp1/test mosquitto_pub -h 192.168.11.18 -t tp1/test -m Hello mosquitto_pub -h 192.168.11.18 -t tp1/test -m Hello mosquitto_pub -h 192.168.11.18 -t tp1/test -m Hello - mosquitto (broker): /usr/local/opt/mosquitto/sbin - mosquitto_sub (for subscription): /usr/local/opt/mosquitto/bin - mosquitto_pub (for publishing): /usr/local/opt/mosquitto/bin - Broker IP address: 192.168.11.18 - Topic name: tp1/test - Message to publish: Hello