In my ongoing endeavors to get my Raspberry Pi to command my stuff I set up a Mosquitto MQTT broker. In the base settings everything went reasonably fine.

I could post test messages with the publish command and receive them with the subscribe command. Then I decided to up the log level and modified the mosquitto.conf file as follows. The version with essentially the whole log section commented out works. The other doesn't.

I narrowed it down to the line with the log file.

$ diff mosquitto.conf mosquitto.conf.old
< #log_dest file /var/log/mosquitto/mosquitto.log
> log_dest file /var/log/mosquitto/mosquitto.log

The file exists and is owned by mosquitto:mosquitto, the user which runs the service.

The very helpful message I do get when trying with the logging is the following:

mosquitto_pub -h localhost -t thisisme -m 5
Error: Connection refused

By now, I'm sure that the service dies a silent death.

$ sudo service mosquitto status
● mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
   Loaded: loaded (/etc/init.d/mosquitto)
   Active: active (exited) since Fri 2017-01-06 11:16:38 CET; 4min 24s ago
  Process: 2222 ExecStop=/etc/init.d/mosquitto stop (code=exited, status=0/SUCCESS)
  Process: 2230 ExecStart=/etc/init.d/mosquitto start (code=exited, status=0/SUCCESS)

Jan 06 11:16:38 T-Pi mosquitto[2230]: Starting network daemon:: mosquitto.
Jan 06 11:16:38 T-Pi systemd[1]: Started LSB: mosquitto MQTT v3.1 message broker.

I'm running Raspbian GNU/Linux 8 (jessie) with the following mosquitto packages:

libmosquitto1/stable,now 1.3.4-2 armhf [installed,automatic]
mosquitto/stable,now 1.3.4-2 armhf [installed]
mosquitto-clients/stable,now 1.3.4-2 armhf [installed]
python-mosquitto/stable,now 1.3.4-2 all [installed]

Further comment requested information:

ls -ld /var /var/log /var/log/mosquitto /var/log/mosquitto/mosquitto.log
drwxr-xr-x 11 root      root       4096 Sep 23 06:02 /var
drwxr-xr-x  8 root      root       4096 Jan  6 21:07 /var/log
drwxr-xr-x  2 mosquitto mosquitto  4096 Jan  5 14:36 /var/log/mosquitto
-rw-r--r--  1 mosquitto mosquitto 14233 Jan  6 21:07 /var/log/mosquitto/mosquitto.log

The only log file in /var/log that gets modified is the auth.log from my sudo.

What did I break?

  • Is there anything written to /var/log/mosquitto/mosquitto.log at all?
    – Aurora0001
    Commented Jan 5, 2017 at 17:06
  • 1
    @Aurora0001 nothing relating to that connection attempt, no
    – Helmar
    Commented Jan 5, 2017 at 17:08
  • Can you try reverting it back to old config file and check? Very dumb: check mosquitto status log
    – bravokeyl
    Commented Jan 6, 2017 at 7:13
  • @bravokeyl, yes, reverting back makes it work again. Then I have no logging though. As per my edit, I narrowed it down to the line with the log file. Works without it, doesn't work with it. Even if directory and file are temporary on 777.
    – Helmar
    Commented Jan 6, 2017 at 9:28
  • @Helmar, which user are you using for the conf file? Can you also check and post the journalctl -xe details after you change conf file with log_dest file
    – bravokeyl
    Commented Jan 6, 2017 at 9:51

3 Answers 3


One way to debug this would be to run mosquitto manually with the same options as your init system is using, then look at the output. For example:

mosquitto -v -c <path to config file>

Adding -v will ensure that you have verbose logging, regardless of the config file settings.

  • 3
    That helped, apparently there's a second mosquitto.conf in /etc/mosquitto which included the one I was using in /etc/mosquitto/conf.d/ . That first file already had that standard log file set. Thus creating an Error: Duplicate "log_dest file" value. which prevented the service from properly starting. Somehow that error didn't get out when using the usual service starting routine.
    – Helmar
    Commented Jan 9, 2017 at 10:01

On Arch Linux (4.4.37-1-ARCH) with mosquitto 1.4.10-2 and an existing logfile/path with permissions as such I cannot reproduce this error.

/var/log/mosquitto $ ls -l
-rw-r--r-- 1 mosquitto root 7832 Jan 5 18:15 mosquitto.log

If the permissions of the logfile however differ, or it does not exist and the directories permission do not allow mosquitto to write to it, starting the broker daemon fails. Which than leads to Error: Connection refused upon publishing or subscribing topics. At least the service does not die a silent death but announces it well in the syslog.

In short with the directory /var/log/mosquitto owned by and writeable by the mosquitto user a log_dest file [...] line in mosquitto's config works just fine.


The log directory/file should be owned by the mosquitto user or the user that you have setup in the conf file and group. I tried with two conf files one with out log_dest file /var/log/mosquitto/mosquitto.log and one with log destination to file.

On my server Mosquitto is running with mosquitto user.

With log_dest file /var/log/mosquitto/mosquitto.log owned by root user is not working with service status error. This probably might be the case for you also. Check the service status after you add log_dest.

I tried changing the ownership of /var/log/mosquitto folder to mosquitto.

sudo chown -R mosquitto:mosquitto /var/log/mosquitto

Then started the service. It's working fine now.

  • I had the user own the file before, now I created a group as well and changed the permissions as suggested, but no luck.
    – Helmar
    Commented Jan 6, 2017 at 10:19
  • @Helmar hmm! this is strange. After you changed the group did you restart or start the service?
    – bravokeyl
    Commented Jan 6, 2017 at 10:20
  • @Helmar Can you cross check again whether (you have created) the log destination directory exists?
    – bravokeyl
    Commented Jan 6, 2017 at 10:25
  • Both the file and the directory exist and are owned by mosquitto:mosquitto
    – Helmar
    Commented Jan 6, 2017 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.