• 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

mosquitto Connection refused

Q&A Forum › mosquitto Connection refused
0 Vote Up Vote Down
mal_rixon asked 3 years ago

Working rhough SMART HOME with Raspberry Pi, ESP32, and ESP8266 page 107 after successfully entering usename andpassword and modifyiying the conf file andrestarting I still get a connection refused error. I also note that sudo systemctl status mosquitto

command gives a status of:

Active: active (exited) not running as per your book.

6 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi.
 
Did you follow the instructions shown in the eBook, or did you already have another mosquitto installation?
 
Try to rerun the following command:

sudo systemctl restart mosquitto

Then, reboot your raspberry pi

sudo reboot

Then, check the status of mosquitto again after the RPi restarts.

sudo systemctl status mosquitto

 
Let me know the results.
Regards,
Sara

0 Vote Up Vote Down
mal_rixon answered 3 years ago

No change after following your instruction.
pi@raspberrypi:~ $ sudo systemctl status mosquitto
● mosquitto.service – LSB: mosquitto MQTT v3.1 message broker
Loaded: loaded (/etc/init.d/mosquitto; generated; vendor preset: enabled)
Active: active (exited) since Tue 2022-09-27 20:22:58 AEST; 1min 31s ago
Docs: man:systemd-sysv-generator(8)
Process: 318 ExecStart=/etc/init.d/mosquitto start (code=exited, status=0/SUCC
Tasks: 0 (limit: 4915)
CGroup: /system.slice/mosquitto.service
Sep 27 20:22:57 raspberrypi systemd[1]: Starting LSB: mosquitto MQTT v3.1 messag
Sep 27 20:22:58 raspberrypi mosquitto[318]: Starting network daemon:: mosquitto.
Sep 27 20:22:58 raspberrypi systemd[1]: Started LSB: mosquitto MQTT v3.1 message
lines 1-11/11 (END)
I have followed the steps in your book apart from the actual pi install.  I had one allready set up and readyto go. This did not include mosquitto however.
 
I examined the password file with nano and it showed the usernames I had put corectly.  Passsowrd was scrambled as expected.  
Broker responded correctly without authentication but after authentication is added I get this.
 
 
mosquitto_pub -d -t testTopic -m “Hello world!” -u mal -P mal
Error: Connection refused
 
 
this is my conf 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 /var/run/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
Thank you for your help.

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi.
I’m not sure why you’re getting that issue.
 
Did you start a new installation of the OS when you started the eBook? Did you install the mosquito from start or did you already have mosquito installed? I’m trying to understand what might be the cause.
 
I found a similar issue: https://github.com/eclipse/mosquitto/issues/641
They mention that if you set the persistence setting to false instead of true in the configuration file, it solves the problem:

persistence false

Let me know if this helps with your issue.
 
Regards,
Sara

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Try only this if the previous workaround doesn’t work.
Also, try changing the following line:

pid_file /var/run/mosquitto.pid

To

pid_file /run/mosquitto/mosquitto.pid

 
 
 
Regards,
Sara

0 Vote Up Vote Down
mal_rixon answered 3 years ago

Thanks for your time Sara.
Tried all the above but no joy so  I blew away the old installation and restrated from scratch with a fresh install everything is now OK and status now says running and not exited.  Authenticated messages now working
 
Thanks again
Mal

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Great!
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

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition 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.