Linux

Where Is Mosquitto Data Stored?

Mosquitto keeps broker persistence in mosquitto.db when persistence is enabled. Config location depends on how the broker was started.

Last updated

Debian and Ubuntu packages use /etc/mosquitto/mosquitto.conf as the main file and /var/lib/mosquitto/mosquitto.db for persistent message data. Upstream defaults use mosquitto.db in the current dir with persistence disabled, so the file may not exist.

Persistence path is set by persistence_location and persistence_file. Confirm the live value in config since admins change defaults and may include files from conf.d style dirs.

Where Mosquitto stores this, by platform

Linux
/var/lib/mosquitto/mosquitto.db

Main config is /etc/mosquitto/mosquitto.conf. Persistence defaults to false, so enable it before expecting a db file. Autosave interval controls write frequency. The mosquitto user needs read and write access to the dir.

Frequently asked questions

Why is there no mosquitto.db file?

Persistence is off by default and data stays in memory only. Set persistence true and set a valid persistence_location to create the file. Check autosave_interval to control how often it writes.

Which config file is actually loaded?

Mosquitto uses the file passed with the config file option or /etc/mosquitto/mosquitto.conf on package installs. It can include extra files from included dirs. Confirm the live value in config and service flags since admins change defaults.

Notice an outdated path? Let us know.