running mosquitto 1.4 overnight, see "Error saving in-memory database, unable to open /var/tmp/m2.db.new for writing, Error: permission denied"

Asked by leo

Hi,
i test to run "sudo mosquitto -v -c /etc/mosquitto/mosquitto.conf" overnight, then see some error messages as below:
Saving in-memory database to /var/tmp/m2.db
Error saving in-memory database, unable to open /var/tmp/m2.db.new for writing
Error: Permission denied.

how to fix this? thanks

Question information

Language:
English Edit question
Status:
Solved
For:
mosquitto Edit question
Assignee:
No assignee Edit question
Solved by:
Roger Light
Solved:
Last query:
Last reply:
Revision history for this message
Best Roger Light (roger.light) said :
#1

If run as root, mosquitto will drop privileges to the "mosquitto" user. If that user does not have permission to the /var/tmp/ directory, it cannot write the persistence file. I would suggest making /var/lib/mosquitto/ and changing the owner to mosquitto, then using that as your persistence location.

Revision history for this message
leo (chleoxu99) said :
#2

thanks for your suggestion, Roger.
i change to use "persistence_location /var/lib/mosquitto/" in the .conf file

Revision history for this message
leo (chleoxu99) said :
#3

Thanks Roger Light, that solved my question.