Mosquitto errors

now my conf file is

user mosquitto
port 1883
pid_file /var/run/
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
allow_anonymous false
password_file /etc/mosquitto/passfile

and i have run chown


disable persistence (set persistence false) and restart the broker. It should become active (running)
check the directory /var/lib/mosquitto/ for the permissions and if any file was created in there

… and start looking for a new SD Card :slight_smile: (it may have data corruption problems…)

stil it dont become active

ok… remove both lines that have something to do with persistence:

persistence true
persistence_location /var/lib/mosquitto/

If this doesn’t work… use process of elimination (remove more lines from the config file… the only line that you really need to bring up the broker is the pid_file config option)

now i got

user mosquitto
port 1883
pid_file /var/run/
persistence true
allow_anonymous false
password_file /etc/mosquitto/passfile

now it’s running and you can test the sub & pub commands.

It seems to me that something is wrong with your /var/lib/mosquitto/ directory. The Broker could not write (and read?) from the persistence file /var/lib/mosquitto/mosquitto.db
It may be that your SD Card is not very happy and needs a change :slight_smile:

1 Like

1 Like

Looks good

You can progress to the next steps
Also, your sonoff should be connecting now to the MQTT Broker… check that also

I would worry about the SD Card if I was you :slight_smile:
Maybe it’s better to get a new one and start with a clean openHABian deployment
Also, make sure that you have a good quality USB Power Supply feeding the Raspberry Pi (I use an “official” PSU)
A proper power feed makes a big difference and keeps your rPi stable and your SD Card happy.

1 Like

how do i make the item for the sonoff th16 temp value and the humidity the setup of the sonoff is

i have a new sd card but how do i move from the old one and to the new one can i do that whitout setting every things up again

the powersupply and sdcard are from raspberry pi and it is only 3 month old

Check the forum for similar posts and if you get stuck, ask for help :wink:

Some hints:

there are many more

You could clone it (
I usually prefer to start clean and configure my system from scratch (but that’s just me)

Corruption can occur due to power loss or fluctuation (while rPi is writing data)
Something was not working with your /var/lib/mosquitto directory…
Did you check permissions and if any file was created in there?
If yes: the file-system could be corrupted (it happens).

1000 thanks for your very big help, I appreciate that very much, this is all new to me

1 Like

If this is still an open issue take a look here:

Hi again Dim

can I somehow see in mosquitto if it receives data from the Sonoff

Hi Brian,

Yes, you can use the subscribe command to monitor the topic that sonoff is publishing messages to.

mosquitto_sub -u openhab -P habopen -t <sonoff_topic> -v

If you don’t know the topic that sonoff uses, you can use (#) for the topic or use a client for MQTT (like: MQTT.fx and subscribe to all topics (#))

To see if the sonoff client is connecting, you could also add the following in your mosquitto.conf:

connection_messages true

This will log the connection in /var/log/mosquitto/mosquitto.log. But not the topic and/or the message.


I finally got my mosquitto to cooperate with openHAB and get messages forwarded from OwnTracks.
But Mosquitto doesn’t seem to run stable over a longer period.
I run version 1.4.14.
And after a couple of days there is no log-file anymore in /var/log/mosquitto - Although I just checked with
systemctl status mosquito
and get the status “active (running)”. And nothing gets sent anymore. When I restart the service everything is back to normal again (for a couple of days).
Any hints what I can check to see what happens?