Mosquitto running on pi as default broker

I have Home assistant auto starting on boot. I have mosquito as the default broker on localhost.
Having difficult trying to auto start mosquitto before auto starting home assistant. Is the sequence order of the autostart important. Its logical that the broker must auto start before ha.

What operating system are you using? What version? What have you tried? What isn’t working? What does the HASS log say about MQTT when it starts?

I believe HASS will just try until it can connect. I know it reconnects when it loses connection.

If you’re using a unit file for systemd, I think you can add a key After or Requires, that maps to the broker unit service.

Excerpts from

After=: The units listed in this directive will be started before starting the current unit. This does not imply a dependency relationship and one must be established through the above directives if this is required.

Requires=: This directive lists any units upon which this unit essentially depends. If the current unit is activated, the units listed here must successfully activate as well, else this unit will fail. These units are started in parallel with the current unit by default.


Platform is raspberry. Installed with all in one script.
I get mqtt to work if I ssh to the pi and execute mosquitto. Then if I restart Ha it works. My problem is getting to auto start mosquitto.
I have the pi to auto restart ha with systemd

Look at how to make a systemd unit file and enable the service here:

Then add:


to the unit file for home assistant under [Unit]. If you already have the After key, add the mosquitto service to that key with a space after the current last value, eg: mosquitto.service

Then reload systemd

systemctl daemon-reload

More info here:

1 Like