• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

MQTT Mosquitto Local only problem

Q&A Forum › MQTT Mosquitto Local only problem
0 Vote Up Vote Down
mosaddeq billah asked 1 year ago

I followed this tutorial . https://randomnerdtutorials.com/cloud-mqtt-mosquitto-broker-access-anywhere-digital-ocean/
Everything ws ok . But if I modify the configuration file as follows 

  1.    at top >> per_listener_settings true 
  2. at bottom >>

allow_anonymous false 
listener 1883
password_file /etc/mosquitto/passwd
 
I get error. 
 
Here is error log 
root@mqtt:~# sudo systemctl restart mosquitto
Job for mosquitto.service failed because the control process exited with error code.
See “systemctl status mosquitto.service” and “journalctl -xeu mosquitto.service” for details.
root@mqtt:~# sudo systemctl status mosquitto.service
× mosquitto.service – Mosquitto MQTT Broker
Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Mon 2024-01-29 03:56:25 UTC; 8s ago
Duration: 4min 45.990s
Docs: man:mosquitto.conf(5)
man:mosquitto(8)
Process: 21241 ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto (code=exited, status=0/SUCCESS)
Process: 21242 ExecStartPre=/bin/chown mosquitto:mosquitto /var/log/mosquitto (code=exited, status=>
Process: 21243 ExecStartPre=/bin/mkdir -m 740 -p /run/mosquitto (code=exited, status=0/SUCCESS)
Process: 21244 ExecStartPre=/bin/chown mosquitto:mosquitto /run/mosquitto (code=exited, status=0/SU>
Process: 21245 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf (code=exited, status=>
Main PID: 21245 (code=exited, status=13)
CPU: 17ms
Jan 29 03:56:25 mqtt systemd[1]: mosquitto.service: Main process exited, code=exited, status=13/n/a
Jan 29 03:56:25 mqtt systemd[1]: mosquitto.service: Failed with result ‘exit-code’.
Jan 29 03:56:25 mqtt systemd[1]: Failed to start mosquitto.service – Mosquitto MQTT Broker.
Jan 29 03:56:25 mqtt systemd[1]: mosquitto.service: Scheduled restart job, restart counter is at 5.
Jan 29 03:56:25 mqtt systemd[1]: Stopped mosquitto.service – Mosquitto MQTT Broker.
Jan 29 03:56:25 mqtt systemd[1]: mosquitto.service: Start request repeated too quickly.
Jan 29 03:56:25 mqtt systemd[1]: mosquitto.service: Failed with result ‘exit-code’.
Jan 29 03:56:25 mqtt systemd[1]: Failed to start mosquitto.service – Mosquitto MQTT Broker.
 
 

Question Tags: #esp8266 #home automation
8 Answers
0 Vote Up Vote Down
Rui Santos Staff answered 1 year ago

Hello mosaddeq,
You’ll also need to follow the instructions to Enable Remote Access and add Authentication, read the section “Mosquitto Broker Enable Remote Access (Authentication: user and password)”

  • https://randomnerdtutorials.com/how-to-install-mosquitto-broker-on-raspberry-pi/

 

0 Vote Up Vote Down
Kai-sven Müller answered 5 months ago

Hello,
I followed the instructions several times, uninstalled Mosquitto, did it again, coped the text from the website and fron the Ebook in the file, but mosquitto did not restart. I also made the user with password successfully. Lokal still works. Restart doies not work at all. What can I O ? 
Text in Confing-File: 
# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example
per_listener_settings true
pid_file /run/mosquitto/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
allow_anonymous false
listener 1883
password_file /etc/mosquitto/passwd
I have a raspberrypi 5 (new) All Steps in the tutorial worked as decribed to that point
 
 
Best Regards, Kai

0 Vote Up Vote Down
Kai-sven Müller answered 5 months ago

Addititon:
sudo systemctl restart mosquitto
Job for mosquitto.service failed because the control process exi ted with error code.
See “systemctl status mosquitto.service” and “journalctl -xeu mo squitto.service” for details.
sudo systemctl status mosquitto
× mosquitto.service – Mosquitto MQTT Broker
Loaded: loaded (/lib/systemd/system/mosquitto.service; ena>
Active: failed (Result: exit-code) since Thu 2024-12-05 23>
Docs: man:mosquitto.conf(5)
man:mosquitto(8)
Process: 3473 ExecStartPre=/bin/mkdir -m 740 -p /var/log/mo>
Process: 3474 ExecStartPre=/bin/chown mosquitto /var/log/mo>
Process: 3475 ExecStartPre=/bin/mkdir -m 740 -p /run/mosqui>
Process: 3476 ExecStartPre=/bin/chown mosquitto /run/mosqui>
Process: 3477 ExecStart=/usr/sbin/mosquitto -c /etc/mosquit>
Main PID: 3477 (code=exited, status=3)
CPU: 14ms
Dec 05 23:54:49 XXXXXXXXXXXXXXXXX systemd[1]: mosquitto.service: >
Dec 05 23:54:49 XXXXXXXXXXXXXXXXX systemd[1]: Stopped mosquitto.s>
Dec 05 23:54:49 XXXXXXXXXXXXXXXXX systemd[1]: mosquitto.service: >
Dec 05 23:54:49 XXXXXXXXXXXXXXXXX systemd[1]: mosquitto.service: >
Dec 05 23:54:49 XXXXXXXXXXXXXXXXX systemd[1]: Failed to start mos>
lines 1-18/18 (END)
× mosquitto.service – Mosquitto MQTT Broker
Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Thu 2024-12-05 23:54:49 CET; 11s ago
Docs: man:mosquitto.conf(5)
man:mosquitto(8)
Process: 3473 ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto (code=exited, status=0/SUCCESS)
Process: 3474 ExecStartPre=/bin/chown mosquitto /var/log/mosquitto (code=exited, status=0/SUCCESS)
Process: 3475 ExecStartPre=/bin/mkdir -m 740 -p /run/mosquitto (code=exited, status=0/SUCCESS)
Process: 3476 ExecStartPre=/bin/chown mosquitto /run/mosquitto (code=exited, status=0/SUCCESS)
Process: 3477 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf (code=exited, status=3)
Main PID: 3477 (code=exited, status=3)
CPU: 14ms
Dec 05 23:54:49 XXXXXXXXXXXXXXXXX[1]: mosquitto.service: Scheduled restart job, restart counter is at 5.
Dec 05 23:54:49 XXXXXXXXXXXXXXXXX[1]: Stopped mosquitto.service – Mosquitto MQTT Broker.
Dec 05 23:54:49 XXXXXXXXXXXXXXXXX[1]: mosquitto.service: Start request repeated too quickly.
Dec 05 23:54:49 XXXXXXXXXXXXXXXXX[1]: mosquitto.service: Failed with result ‘exit-code’.
Dec 05 23:54:49 XXXXXXXXXXXXXXXXX[1]: Failed to start mosquitto.service – Mosquitto MQTT Broker.
 
 

0 Vote Up Vote Down
Sara Santos Staff answered 5 months ago

Hi.
Can you tell me the exact tutorials that you’re following?
Is it from an eBook? Which one? And on which page are you getting stuck?
Regards,
Sara

0 Vote Up Vote Down
Kai-sven Müller answered 5 months ago

Thank you for the quick response. It is the follwoing E-book:
SMART HOME with Raspberry Pi, ESP32, and ESP8266

0 Vote Up Vote Down
Kai-sven Müller answered 5 months ago

… and I stuck on page 113 doing the restart od Mosquitto:
sudo systemctl restart mosquitto

Wait a few seconds. Then to check if Mosquitto is running, you can type the following
command:
sudo systemctl status mosquitto

Now, you have authentication with username and password enabled.
If

0 Vote Up Vote Down
Kai-sven Müller answered 5 months ago

Did the same today, removed everything,
sudo apt remove mosquitto
sudo apt purge mosquitto
sudo apt install mosquitto
 
installes again, followed the inst´ructions and it worked (???).
Again thank you for yuor help.

0 Vote Up Vote Down
Sara Santos Staff answered 5 months ago

Great.
I’m glad everything is working as expected now.
I’ll mark this issue as resolved. If you need further help, you just need to open a new question in our forum.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.