Mosquitto won't start

Hello, I need help.
I’ve installed home assistant on raspian stretch lite next i have installed mosquitto broker and client. All works, but when i restart raspberry, mqtt broker didn’t start, i have to write in console “mosquitto -d” and then all works perfectly again. I have already modified systemd Service to run it at startup.
Please help me
Thank you

What output do you get with

systemctl status mosquitto.service

When you reboot and mosquitto isn’t running, whats the output of

sudo systemctl status mosquitto.service

What happens if you try and start it with

sudo systemctl start mosquitto.service

Hello dear, thank you for quick reply:

sudo systemctl status mosquitto.service

i have following result:

mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
Loaded: loaded (/etc/init.d/mosquitto; generated; vendor preset: enabled)
Active: active (exited) since Fri 2018-08-03 12:49:53 CEST; 49s ago
Docs: man:systemd-sysv-generator(8)
Process: 331 ExecStart=/etc/init.d/mosquitto start (code=exited, status=0/SUCC
CGroup: /system.slice/mosquitto.service

ago 03 12:49:53 raspberrypi systemd[1]: Starting LSB: mosquitto MQTT v3.1 messag
ago 03 12:49:53 raspberrypi mosquitto[331]: Starting network daemon:: mosquitto.
ago 03 12:49:53 raspberrypi systemd[1]: Started LSB: mosquitto MQTT v3.1 message

sudo systemctl start mosquitto.service

nothing happens, it returns blank prompt.

Home assistant homepage like so:

As you see, switch isn’t loaded, but if i write mosquitto -d in the prompt all return to works.

this is my configuration.yaml

port: 1883
client_id: home-assistant-1
username: homeassistant
password: xxxx


  • platform: mqtt
    name: “Sonoff power”
    state_topic: “stat/sonoff_1/POWER”
    command_topic: “cmnd/sonoff_1/POWER”
    availability_topic: “tele/sonoff_1/LWT”
    qos: 1
    payload_on: “ON”
    payload_off: “OFF”
    payload_available: “Online”
    payload_not_available: “Offline”
    retain: true

Step that i have follow:
start Raspberry
wait for HA
write mosquitto -d in console
then restart HA

I have thinked that HA not able to connect to broker so i have write in [email protected] this:

Description=Home Assistant mosquitto.service influxdb.service

ExecStart=/srv/homeassistant/bin/hass -c “/home/homeassistant/.homeassistant”


but nothing is changed!

This shows that mosquitto started and then stops. Unless you have changed it, the init.d script runs the configuration file at /etc/mosquitto/mosquitto.conf, so I suggest trying that on the command line to see if it gives an error

mosquitto -c /etc/mosquitto/mosquitto.conf
1 Like

No command that you suggest give me no error; i have wrote
sudo mosquitto -c /etc/mosquitto/mosquitto.conf
It returns prompt

So does mine, and mine is running fine.

I’ve found my log files under


sudo cat /var/log/mosquitto/mosquitto.log

That will output the log to your screen. I suggest you reboot, then do the above command to see what the last few items are in that log.


Ok,log show me an error:

1533307124: Config loaded from /etc/mosquitto/mosquitto.conf.
1533307124: Error: Unable to open pwfile “/etc/mosquitto/pwfile▒”.
1533307124: Error opening password file “/etc/mosquitto/pwfile▒”.
1533310484: mosquitto version 1.4.10 (build date Fri, 22 Dec 2017 08:19:25 +0000

I have created pwfile with follow command:
sudo mosquitto_passwd -c /etc/mosquitto/pwfile homeassistant

and then i have added following line:

allow_anonymous false
password_file /etc/mosquitto/pwfile
listener 1883

to mosquitto.conf.

I DIDN’T SAW space after pwfile…

OHHH Thank you, i have removed space and now all works! :slight_smile:

Thank you Thank you!!!

1 Like

Not a problem, you fixed it, i just point you in the right direction.

1 Like

mine doesn’t even attempt to start??? any suggestions?