MQTT didn't work anymore

Hi,

today i have seen that mq MQTT connection didn’t work anymore.

in the logs i can see this message every 60000ms.
i also tried to reinstall mqtt broker via openhabian but also this didn’t solve my problem.

22:26:57.495 [INFO ] [t.reconnect.PeriodicReconnectStrategy] - Try to restore connection to '127.0.0.1'. Next attempt in 60000ms
22:26:57.502 [INFO ] [o.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '127.0.0.1' with clientid 

but when i check my mqtt broker status, everything looks fine.

sudo systemctl status mosquitto
● mosquitto.service - Mosquitto MQTT Broker
     Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; preset: enabled)
     Active: active (running) since Sun 2025-01-19 21:47:14 CET; 41min ago
       Docs: man:mosquitto.conf(5)
             man:mosquitto(8)
   Main PID: 751 (mosquitto)
      Tasks: 1 (limit: 3916)
        CPU: 2.346s
     CGroup: /system.slice/mosquitto.service
             └─751 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

Jän 19 21:47:14 openhabian systemd[1]: Started mosquitto.service - Mosquitto MQTT Broker.

Post the code tab contents of your MQTT broker.

Where can I find it?

On the right side of that photo it shows “Code”. Click there then copy and paste.

MQTT/Code

UID: mqtt:broker:pibroker
label: MQTT Broker
thingTypeUID: mqtt:broker
configuration:
  lwtQos: 0
  publickeypin: true
  keepAlive: 60
  hostnameValidated: true
  secure: false
  birthRetain: true
  shutdownRetain: true
  certificatepin: true
  password: test
  protocol: TCP
  qos: 0
  reconnectTime: 60000
  mqttVersion: V3
  host: 127.0.0.1
  lwtRetain: true
  username: openhabmqqt
  enableDiscovery: true

since i didn’t change anything i don’t understand why it didn’t work. I only changed last time ssh access.

EDIT: in sudo tail -f /var/log/mosquitto/mosquitto.log i can see:

1737324219: Client connection from 127.0.0.1 denied access by tcpd.

Check your mosquitto.conf file (/etc/mosquitto.conf). See if 127.0.0.1 is allowed.

To test you could put

allow_anonymous true

To see if you can make it work.

hi, there is no mosquitto.conf file

edit: i found it here: /etc/mosquitto/mosquitto.conf
but also changing allow_anonymous to true nothing changed :frowning:

Did you restart mosquitto after the change?

Something is denying access. Search for this on the web. Many solutions out there, you may have to work through them.

If this was the moment you saw failure, I would revisit this change.

i try now to deinstall Mosquitto with sudo apt remove mosquitto but now i can’t install mqtt broker with openhabian :frowning:

i found the problem.

first, i installed mosquitto with sudo apt-get install mosquittoand then i could reinstall MQTT broker via openhabian.

the problem for denied access by tcpd was because i used the blocking list sudo nano /etc/hosts.deny .

after i deactivate to block all it was working again.

1 Like