Hello- Setting up Mosquitto on raspberrypi 5 for localhost only. Getting “connection refused” and “permission denied” errors. Please advise where would be the right place for me to seek assistance. Thank you-
This usually comes down to the stricter defaults in Mosquitto v2.0+ and directory ownership in Bookworm. Try these steps:
1. Check File Permissions
The service needs read access to the config and write access to its storage. Run:
-
Config:
sudo chown root:root /etc/mosquitto/mosquitto.conf && sudo chmod 644 /etc/mosquitto/mosquitto.conf -
Storage:
sudo chown -R mosquitto:mosquitto /var/lib/mosquitto/
2. Update the Config (Localhost Only)
Mosquitto now refuses all connections by default. Edit your config (sudo nano /etc/mosquitto/mosquitto.conf) and ensure these lines exist:
Plaintext
listener 1883 127.0.0.1
allow_anonymous true
3. Restart and Verify
Bash
sudo systemctl restart mosquitto
sudo systemctl status mosquitto
If it still fails, run sudo journalctl -u mosquitto -n 20 to see the specific line causing the “Permission Denied” error. Often it’s a log file or persistence file path that wasn’t created with the right user.
Very good- Thank you for your assistance. I issued the commands you gave me, and added the lines to mosquitto.conf- then ran sub pub test: NO JOY.
I attached a TXT file of all the screen shots of my situation- for your review.
I intend to use Mosquitto for sub/pub function on the Rpi: ie: it is running on the very same box as is the weather (weewx) application.
mosquitto_2.txt (3.7 KB)
Hello Eric,
From what I see right now, the logs look good. You have a running system with clients connecting.
I think the clientids with “auto-…” are your clients.
If you do not receive any messages, this is probably because of access rights.
How have you configured your configuration file?
Here is my current config information. Attached file mosquitto.inf text
file.
My goal is to have mosquitto handle weather loop packet data from my
weather station and then upload that data to my weather web site.
/Eric
(Attachment mosquitto.info is missing)