MQTT Issues

Hello,

I configured MQTT exactly how Ben shows in his video on Youtube (BRUH Automation). It worked when I configured it. After reboot, I found that it does not work. When I try to run mosquitto_sub command, I have the following:

    pi@Home-Assistant:~ $ mosquitto_sub -d -u username -P password -t "dev/test"
    Error: Connection refused

After long testing, I found that Mosquitto service is not running:

    pi@Home-Assistant:~ $ sudo systemctl status mosquitto.service
    ● mosquitto.service - Mosquitto MQTT Broker
       Loaded: loaded (/lib/systemd/system/mosquitto.service; disabled)
       Active: inactive (dead)
         Docs: man:mosquitto(8)
               https://mosquitto.org/
    pi@Home-Assistant:~ $

I found that if I want it to work, I have to manually run the following commands:

    sudo systemctl stop home-assistant.service
    sudo systemctl start mosquitto
    sudo systemctl start home-assistant.service

After I run above three commands, everything works.
What is wrong? How can I fix it?

Thank you.

You may have forgotten to enable the service. Try:

sudo systemctl enable mosquitto

That fixed it!!! thank you.