Failed to start Mosquitto MQTT Broker

Hi,

i have updated Mosquitto MQTT Broker on my Ubuntu 20.04 and now it doesn’t work. In fact of that i removed it completely and install it again. It works, but only until next restart.

Than i’ve added a custom.conf to /etc/mosquitto/conf.d

allow_anonymous true
listener 1883

It works well untill i restarted the system.

I try to find a solution and start the server with

sudo /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

I’ll get the message that the pid_file is unable to create. I must add the missing folder to /var/run/ and change the owner to

sudo chown mosquitto:mosquitto /var/run/mosquitto

Now the error message doesn’t shown but the pid_file is not written and mosquitto doesn’t start.

Than i try to do that: sudo /usr/sbin/mosquitto

The Result is that Error:

1607991918: mosquitto version 2.0.2 starting
1607991918: Using default config.
1607991918: Starting in local only mode. Connections will only be possible from clients running on this machine.
1607991918: Create a configuration file which defines a listener to allow remote access.
1607991918: Opening ipv4 listen socket on port 1883.
1607991918: Error: Address already in use
1607991918: Opening ipv6 listen socket on port 1883.
1607991918: Error: Address already in use

Anyway it will not start, but if i delete it completely and install it again it will run properly until the next restart. Could anybody help me, because my smart home wont work.

Now it is getting very strange. The Broker seems to work because i could switch on and of lights via openhab2. But that is what sudo systemctl status mosquitto shows:

mosquitto.service - Mosquitto MQTT Broker
Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; vendor pre>
Active: failed (Result: exit-code) since Tue 2020-12-15 01:08:51 CET; 27mi>
Docs: man:mosquitto.conf(5)
man:mosquitto(8)
Process: 8053 ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto (code=ex>
Process: 8054 ExecStartPre=/bin/chown mosquitto: /var/log/mosquitto (code=e>
Process: 8055 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.con>
Main PID: 8055 (code=exited, status=1/FAILURE)

Dez 15 01:08:51 PC-Server systemd[1]: mosquitto.service: Main process exited, c>
Dez 15 01:08:51 PC-Server systemd[1]: mosquitto.service: Failed with result 'ex>
Dez 15 01:08:51 PC-Server systemd[1]: Failed to start Mosquitto MQTT Broker.
Dez 15 01:08:51 PC-Server systemd[1]: mosquitto.service: Scheduled restart job,>
Dez 15 01:08:51 PC-Server systemd[1]: Stopped Mosquitto MQTT Broker.
Dez 15 01:08:51 PC-Server systemd[1]: mosquitto.service: Start request repeated>
Dez 15 01:08:51 PC-Server systemd[1]: mosquitto.service: Failed with result 'ex>
Dez 15 01:08:51 PC-Server systemd[1]: Failed to start Mosquitto MQTT Broker.

I really do not understand what is going on.

Best regards
Chris

As this is an openHAB forum: do you have anything else on your system already attached to port 1883, perhaps openHAB’s embedded broker?

Try running the following command:

netstat -tulpn

or

ss -tulpn | grep :1883

in your Ubuntu terminal to see what other process is using port 1883. You might need to sudo depending on your privileges.

1 Like

I also broke MQTT, it was installed from:

apt-add-repository ppa:mosquitto-dev/mosquitto-ppa

i deleted it:

apt purge mosquitto

and removed the link to the repository
then installed it from ubuntu repository
and now it works.

1 Like

Awesome! Now it work’s fine! Many thanks to all of you, helped me in this Situation.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.