HiveMQ service fails to start on Ubuntu server boot
Problem
The HiveMQ service fails to start on boot after following the instructions provided in the HiveMQ Documentation.
Solution
We suggest using Systemd service to run HiveMQ as a service.
Copy the HiveMQ service file to the systemd directory:
sudo cp /opt/hivemq/bin/init-script/hivemq.service /etc/systemd/system/hivemq.serviceEdit the HiveMQ service file to run as root instead of the default hivemq user:
sudo nano /etc/systemd/system/hivemq.serviceUpdate Service Group and User as “root”.
Reload systemd to apply the changes made to the HiveMQ service file. Use following command to do that.
sudo systemctl daemon-reloadEnable HiveMQ to start on boot. Following command configures systemd to start the HiveMQ service automatically on boot.
sudo systemctl enable hivemqManually start the HiveMQ service:
sudo systemctl start hivemq.serviceCheck the status of the HiveMQ service:
sudo systemctl status hivemq.serviceThis command displays the status of the HiveMQ service, including whether it is running or not.
Debug the HiveMQ startup process with systemd:
sudo journalctl | grep -i hivemqCheck if HiveMQ is listening to the default port for MQTT:
sudo netstat -an | grep 1883In case firewalls such as UFW are enabled, Please try disabling these and retry to run the hivemq service. Or allow mqtt and control centre ports configured in HiveMQ’s config.xml to become accessible. Following is the command to disable UFW
sudo ufw disableEven after doing all of the above still service fails to restart then this could be because of Ubuntu AppArmor or SELinux configurations that may interfere with the service. Please try disabling them and retry if the service starts without issue. Following are the commands to stop and disable the AppArmor service.
sudo systemctl stop apparmor.service sudo systemctl disable apparmor.serviceIn case the issue persists, please reach out to support via the Support portal for further help.