mosquitto Error: Address already in use Topic is solved

Having issues with your DietPi installation or found a bug? Post it here.
User avatar
Joulinar
Posts: 4203
Joined: Sat Nov 16, 2019 12:49 am

Re: mosquitto Error: Address already in use

Post by Joulinar »

Well DietPi doesn't do anything on that update. It is an apt package directly installed from mosquitto repository using apt package manager. Probably this is behavior of mosquitto v2 as security requirements changed. But better to check with mosquitto directly
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
novitibo
Posts: 116
Joined: Mon Feb 29, 2016 5:11 pm

Re: mosquitto Error: Address already in use

Post by novitibo »

after mosquitto upgrade:

DietPi-Services
─────────────────────────────────────────────────────
Mode: status mosquitto

[ INFO ] DietPi-Services | mosquitto inactive (dead)

with "dietpi-software reinstall 123" no luck also
User avatar
Joulinar
Posts: 4203
Joined: Sat Nov 16, 2019 12:49 am

Re: mosquitto Error: Address already in use

Post by Joulinar »

pls share following

Code: Select all

systemctl status mosquitto.service
cat /var/log/mosquitto/mosquitto.log
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
novitibo
Posts: 116
Joined: Mon Feb 29, 2016 5:11 pm

Re: mosquitto Error: Address already in use

Post by novitibo »

Code: Select all

root@DietPi:/etc/mosquitto# systemctl status mosquitto.service
● mosquitto.service - Mosquitto MQTT Broker daemon
   Loaded: loaded (/etc/systemd/system/mosquitto.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

Mar 23 14:02:42 DietPi systemd[1]: /etc/systemd/system/mosquitto.service:11: PIDFile= referen
ces path below legacy directory /var/run/, updating /var/run/mosquitto.pid → /run/mosquitto.pid; please update the un
it file accordingly.
Mar 23 14:02:57 DietPi systemd[1]: /etc/systemd/system/mosquitto.service:11: PIDFile= referen
ces path below legacy directory /var/run/, updating /var/run/mosquitto.pid → /run/mosquitto.pid; please update the un
it file accordingly.
Mar 23 14:02:57 DietPi systemd[1]: Started Mosquitto MQTT Broker daemon.
Mar 23 14:02:57 DietPi systemd[1]: mosquitto.service: Succeeded.
Mar 23 14:03:38 DietPi systemd[1]: /etc/systemd/system/mosquitto.service:11: PIDFile= referen
ces path below legacy directory /var/run/, updating /var/run/mosquitto.pid → /run/mosquitto.pid; please update the un
it file accordingly.
Mar 23 14:06:03 DietPi systemd[1]: /etc/systemd/system/mosquitto.service:11: PIDFile= referen
ces path below legacy directory /var/run/, updating /var/run/mosquitto.pid → /run/mosquitto.pid; please update the un
it file accordingly.
Mar 23 14:06:14 DietPi systemd[1]: /etc/systemd/system/mosquitto.service:11: PIDFile= referen
ces path below legacy directory /var/run/, updating /var/run/mosquitto.pid → /run/mosquitto.pid; please update the un
it file accordingly.
Mar 23 14:06:14 DietPi systemd[1]: Started Mosquitto MQTT Broker daemon.
Mar 23 14:06:14 DietPi systemd[1]: mosquitto.service: Succeeded.
Mar 23 14:07:19 DietPi systemd[1]: /etc/systemd/system/mosquitto.service:11: PIDFile= referen
ces path below legacy directory /var/run/, updating /var/run/mosquitto.pid → /run/mosquitto.pid; please update the un
it file accordingly.

log file is empty :?
User avatar
Joulinar
Posts: 4203
Joined: Sat Nov 16, 2019 12:49 am

Re: mosquitto Error: Address already in use

Post by Joulinar »

can you share you config file pls

Code: Select all

cat /etc/mosquitto/mosquitto.conf
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
novitibo
Posts: 116
Joined: Mon Feb 29, 2016 5:11 pm

Re: mosquitto Error: Address already in use

Post by novitibo »

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

pid_file /var/run/mosquitto.pid

persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log

allow_anonymous false
password_file /etc/mosquitto/users.passwd
listener 1883
User avatar
Joulinar
Posts: 4203
Joined: Sat Nov 16, 2019 12:49 am

Re: mosquitto Error: Address already in use

Post by Joulinar »

pls can you able the line with pointing to the mosquitto.pid file. Should looks like this

Code: Select all

#pid_file /var/run/mosquitto.pid
pid_file /run/mosquitto/mosquitto.pid
pls check if directory /run/mosquitto/ exist

and restart mosquitto afterwards.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
novitibo
Posts: 116
Joined: Mon Feb 29, 2016 5:11 pm

Re: mosquitto Error: Address already in use

Post by novitibo »

that folder was not there, I created it, rebooted the system and...

[ INFO ] DietPi-Services | mosquitto inactive (dead) :x :cry:
User avatar
MichaIng
Site Admin
Posts: 2780
Joined: Sat Nov 18, 2017 6:21 pm

Re: mosquitto Error: Address already in use

Post by MichaIng »

That's a tmpfs (RAMdisk), any files there are to live only for the lifetime the service runs. When the default configuration uses /run/mosquitto.pid that's fine as no directory needs to be created. But the daemon does not have permissions to create a file there, which is probably the reason for the issue. Is the PID file really created by default there or did you add/set that setting manually? It would be basically a bug with their systemd unit as unprivileged users are never intended to create files there, so the systemd unit must handle this with root privileges. The PID file is actually not required with systemd, so the cleanest solution wound be to unset that setting.
Post Reply