Engineering summary
Step-by-step Mosquitto setup on Ubuntu, from apt install to systemctl, remote listeners, pub/sub testing and password protection, as QuakeLogic uses it to drive IP-based earthquake sirens.
In short: To install an MQTT broker on Ubuntu, run sudo apt update, sudo apt install mosquitto mosquitto-clients, then sudo systemctl enable mosquitto and sudo systemctl start mosquitto. Mosquitto listens on port 1883 and allows anonymous clients by default; test it with mosquitto_sub and mosquitto_pub. For production, add a password file and TLS. QuakeLogic uses MQTT to deliver earthquake early warning messages to IP-based sirens.
MQTT (Message Queuing Telemetry Transport) is a lightweight messaging protocol designed for constrained devices and low-bandwidth, high-latency, or unreliable networks. It is widely used in IoT (Internet of Things) applications to facilitate communication between devices. In this guide, we will walk you through the steps to install and start an MQTT broker on Ubuntu using Mosquitto, a popular MQTT broker.
At QuakeLogic, we often use the MQTT service to deliver earthquake early warning messages, for example to activate the IP-based sirens that operate over the network.

Step 1: Update Your System
Before installing any new software, it’s always a good idea to update your package list to ensure you have the latest version of all your installed packages.
sudo apt update
Step 2: Install Mosquitto and Mosquitto Clients
Mosquitto is a lightweight MQTT broker that is easy to install and configure. The Mosquitto clients package includes command-line tools to test your setup.
sudo apt install mosquitto mosquitto-clients
Step 3: Enable and Start the Mosquitto Service
Once installed, you need to enable the Mosquitto service to start on boot and then start the service.
- Enable the Mosquitto service:
sudo systemctl enable mosquitto - Start the Mosquitto service:
sudo systemctl start mosquitto - Check the status of the Mosquitto service:
sudo systemctl status mosquittoYou should see an output indicating that Mosquitto is active and running.
Step 4: Configure Mosquitto (Optional)
By default, Mosquitto is configured to allow anonymous connections on port 1883. For more advanced configurations, you can edit the Mosquitto configuration file located at /etc/mosquitto/mosquitto.conf.
- Open the configuration file:
sudo nano /etc/mosquitto/mosquitto.conf - Example configuration for allowing remote connections:
listener 1883 allow_anonymous true - Save and exit the file, then restart Mosquitto to apply changes:
sudo systemctl restart mosquitto
Step 5: Test Mosquitto
To ensure Mosquitto is working correctly, you can use the Mosquitto clients to publish and subscribe to messages.
- Open two terminal windows.
- In the first terminal window, subscribe to a topic:
mosquitto_sub -h localhost -t test/topic - In the second terminal window, publish a message to the topic:
mosquitto_pub -h localhost -t test/topic -m "Hello MQTT"
You should see the message “Hello MQTT” appear in the first terminal window.
Step 6: Secure Mosquitto (Optional)
For production environments, it is important to secure your MQTT broker. You can enable password protection and TLS/SSL encryption.
- Create a password file:
sudo mosquitto_passwd -c /etc/mosquitto/passwd username - Edit the Mosquitto configuration to use the password file:
allow_anonymous false password_file /etc/mosquitto/passwd - Restart Mosquitto:
sudo systemctl restart mosquitto
For TLS/SSL encryption, you need to generate certificates and configure Mosquitto to use them. Detailed instructions can be found in the Mosquitto documentation.
Conclusion
By following these steps, you can easily set up an MQTT broker on your Ubuntu system using Mosquitto. This setup will allow you to facilitate communication between IoT devices efficiently. For more advanced configurations and security setups, refer to the Mosquitto documentation or reach out to the community for support.
About QuakeLogic
QuakeLogic is a leading provider of advanced seismic monitoring solutions, offering a range of products and services designed to enhance the accuracy and efficiency of seismic data acquisition and analysis. Our innovative technologies and expert support help organizations worldwide to better understand and mitigate the impacts of seismic events.
Contact Information
- Email: sales@quakelogic.net
- Phone: +1-916-899-0391
- WhatsApp: +1-650-353-8627
- Website: www.quakelogic.net
For more information about our products and services, please visit our website or contact our sales team. We are here to help you with all your seismic monitoring needs.
Thank you for choosing QuakeLogic. We look forward to assisting you with your seismic monitoring projects. Stay tuned to our blog for more tips and guides on using seismic monitoring tools and other technological solutions!
Key Takeaways
- Install with sudo apt update followed by sudo apt install mosquitto mosquitto-clients.
- Enable at boot and start: sudo systemctl enable mosquitto, sudo systemctl start mosquitto; verify with systemctl status.
- Default config allows anonymous connections on port 1883; edit /etc/mosquitto/mosquitto.conf and add listener 1883 for remote clients.
- Test with mosquitto_sub -h localhost -t test/topic in one terminal and mosquitto_pub -t test/topic -m 'Hello MQTT' in another.
- Secure production brokers with mosquitto_passwd, allow_anonymous false and TLS certificates.
Frequently Asked Questions
Update the package list with sudo apt update, then install the broker and command-line tools with sudo apt install mosquitto mosquitto-clients. Enable the service to start at boot using sudo systemctl enable mosquitto, start it with sudo systemctl start mosquitto, and confirm it is active with sudo systemctl status mosquitto. The broker is then listening on port 1883.
Open two terminals. In the first, subscribe to a topic with mosquitto_sub -h localhost -t test/topic. In the second, publish with mosquitto_pub -h localhost -t test/topic -m "Hello MQTT". If the message appears in the first terminal, the Mosquitto broker is routing messages correctly between clients and the installation is complete.
Edit /etc/mosquitto/mosquitto.conf with sudo nano and add listener 1883 together with allow_anonymous true for an open test broker, then restart with sudo systemctl restart mosquitto. Also make sure port 1883 is open in any firewall. For anything beyond a lab test, replace anonymous access with a password file and TLS encryption.
Create a password file with sudo mosquitto_passwd -c /etc/mosquitto/passwd username, then set allow_anonymous false and password_file /etc/mosquitto/passwd in the configuration and restart Mosquitto. For encryption, generate certificates and configure a TLS listener as described in the Mosquitto documentation. Password protection plus TLS is the minimum for a production broker.
MQTT is a lightweight publish/subscribe protocol built for constrained devices and low-bandwidth or unreliable networks, which makes it well suited to pushing time-critical alerts to many endpoints at once. QuakeLogic uses an MQTT broker to deliver earthquake early warning messages, for example to activate IP-based sirens across a network the moment a warning is issued.
Related Articles
- Oil & Gas Seismic Safety
- SMR Seismic Monitoring Systems for Nuclear and AI Facilities
- Why You Need a Hybrid Earthquake Early Warning System
- 🪐 SATURN Series Smart Seismic Switch — Intelligent Earthquake Detection for Industrial Safety
Need help with a project? QuakeLogic designs and supplies seismic monitoring, earthquake early warning, structural health monitoring, infrasound, and shake table systems. Browse QuakeLogic products or contact our engineering team with your site, structure, or test requirements.
Related
Discover more from QuakeLogic
Subscribe to get the latest posts sent to your email.
Reviewed by
QuakeLogic
Published by QuakeLogic engineers and seismic monitoring specialists. QuakeLogic designs earthquake early warning, structural health monitoring, infrasound, vibration monitoring, and shake table testing systems for infrastructure, research, public safety, and industrial engineering teams.
Topic cluster
Related engineering knowledge areas
- Structural Health MonitoringMonitoring for bridges, buildings, dams, tunnels, industrial facilities, and resilient infrastructure.
- Earthquake Early WarningOn-site detection, alerting workflows, seismic switches, and critical infrastructure warning systems.
- Infrasound MonitoringLow-frequency acoustic sensing for environmental noise, blast, UAV, volcano, and defense applications.
- Shake TablesUniaxial, biaxial, vertical, geotechnical, and multi-axis shake table testing systems.
Definitions and references
Terms, standards, and source cues
- SHM: related to Structural Health Monitoring in this QuakeLogic knowledge cluster.
- damage detection: related to Structural Health Monitoring in this QuakeLogic knowledge cluster.
- earthquake early warning: related to Earthquake Early Warning in this QuakeLogic knowledge cluster.
- seismic switch: related to Earthquake Early Warning in this QuakeLogic knowledge cluster.
- infrasound sensors: related to Infrasound Monitoring in this QuakeLogic knowledge cluster.
- low-frequency noise: related to Infrasound Monitoring in this QuakeLogic knowledge cluster.
- shake tables: related to Shake Tables in this QuakeLogic knowledge cluster.
- AC156: related to Shake Tables in this QuakeLogic knowledge cluster.
Next reading
Related engineering articles
Need project support?
Talk with QuakeLogic about monitoring, testing, or warning systems.
Get engineering guidance for seismic monitoring, structural health monitoring, infrasound, vibration, earthquake early warning, and shake table applications.

