Fresh installation, Mosquitto not accessible

I just installed a fresh sd-card with Openhabian from the latest download image.
Added Mosquitto via ‘sudo openhabian-config’
It’s working locally in a terminal, I can look with
mosquitto_sub -v -t '#'
and in another terminal to the same raspberry I can post with
mosquitto_pub -t 'test' -m 'message'
Now my other (previously working MQTT devices) can’t access any more the newly installed Broker. I’ve already installed many devices without Mosquitto problems.
Is there something broken in the installation or latest version of Mosquitto?
Kind Regards, Hans

Maybe interesting to post : I tried to post from another raspberry terminal with

mosquitto_pub -h 10.0.0.41 -t 'test' -m 'message'
Error: Connection refused

During installation I left the pwd empty.

I think latest versions of mosquitto block anonymous by default. Are your devices authenticating?

You probably need to add “allow_anonymous true” to your /etc/mosquitto/mosquitto.conf

Run

sudo netstat -tulpn | grep mosquitto

on your raspberry that has mosquitto as server/broker.
Should show something like

tcp        0      0 0.0.0.0:1883            0.0.0.0:*               LISTEN      3056/mosquitto      
tcp6       0      0 :::1883                 :::*                    LISTEN      3056/mosquitto

which means it is listening on port 1883 for ethernet and localhost.
If it just show 127.0.0.1 then it only listens to localhost which wold explain connection refuse for the remote host.
In case it does not list any process at all the process is not running. That cannot be the reason as the local client is able to publish a message.

I get

tcp        0      0 127.0.0.1:1883          0.0.0.0:*               LISTEN      3101/mosquitto
tcp6       0      0 ::1:1883                :::*                    LISTEN      3101/mosquitto

OK. It’s listens only locally…
How to enable listening to ethernet?

Oh yes, if you don’t have a conf file, it only will listen locally as I understand it.

Try making an /etc/mosquitto/mosquitto.conf file with and restart mosquitto:

# 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 /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

listener 1883
allow_anonymous true

Hmm, I mean, I don’t have a local configuration file.
Now I created and copied yours to the folder conf.d

Still same problem. He’s not looking to ethernet, only locally.
Looks like the latest version is having this as default.
Any idea how to enable?

No, that file should be in /etc/mosquitto/ with the filename mosquitto.conf

Putting it in the conf.d won’t work as that folder is defined as included in the file that is missing and we are creating.

The comment section at the top of the file may be misleading you. /etc/mosquitto/conf.d/ is the recommended location to put custom config but that’s not what we are doing right now. Sorry for the confusion.

OK. We are getting there !
I found on another forum that I have to add following 2 lines to the default mosquitto.conf:

listener 1883 0.0.0.0
allow_anonymous true

When checking you can see:

sudo netstat -tulpn | grep mosquitto
tcp        0      0 0.0.0.0:1883            0.0.0.0:*               LISTEN      679/mosquitto

Solved.

1 Like

Fresh openhabian install on Rpi4. Installed mosquitto via the openhab-config. Mosquitto cleints failed to connect until I found this fix. Thanks.

It used install problem free. Tis new issue wasted my weekend.


sudo systemctl stop mosquitto.service
sudo nano /etc/mosquitto/mosquitto.conf

Add:

listener 1883 0.0.0.0
allow_anonymous true
sudo systemctl start mosquitto.service