Mosquitto broker restarts every few minutes

Hi
i’m using HA with the Mosquitto broker add on for few years already. it was working fine until ~ a months ago, where is started seeing many devices becoming ‘unavailable’ in HA.
after some debug, i discovered that the root cause for the problem is due to many restarts of the broker, not the clients (which are openbacken devices)

has anyone experienced similar issue? any ideas to debug?

  • Installation method Home Assistant OS
  • Core 2025.12.5
  • Supervisor 2025.12.3
  • Operating System 16.3
  • Frontend 20251203.3

Here is simple log example from today:

||Line 9276: 2026-01-03 08:06:51: mosquitto version 2.0.22 starting|
||Line 9310: 2026-01-03 08:07:38: mosquitto version 2.0.22 starting|
||Line 9341: 2026-01-03 08:10:39: mosquitto version 2.0.22 starting|
||Line 9375: 2026-01-03 08:14:43: mosquitto version 2.0.22 starting|
||Line 9407: 2026-01-03 08:18:45: mosquitto version 2.0.22 starting|
||Line 9439: 2026-01-03 08:20:55: mosquitto version 2.0.22 starting|
||Line 9470: 2026-01-03 08:22:44: mosquitto version 2.0.22 starting|
||Line 9505: 2026-01-03 08:24:53: mosquitto version 2.0.22 starting|
||Line 9563: 2026-01-03 08:51:01: mosquitto version 2.0.22 starting|
||Line 9617: 2026-01-03 08:51:45: mosquitto version 2.0.22 starting|
||Line 9658: 2026-01-03 09:04:51: mosquitto version 2.0.22 starting|
||Line 9720: 2026-01-03 09:35:44: mosquitto version 2.0.22 starting|
||Line 9751: 2026-01-03 09:37:29: mosquitto version 2.0.22 starting|
||Line 9788: 2026-01-03 09:45:28: mosquitto version 2.0.22 starting|
||Line 9821: 2026-01-03 09:49:55: mosquitto version 2.0.22 starting|
||Line 9887: 2026-01-03 10:26:01: mosquitto version 2.0.22 starting|
||Line 9963: 2026-01-03 11:11:44: mosquitto version 2.0.22 starting|

in between the restarts i can see the clients connection, and regular db activity like:

  • New client connected from 192.168.1.XXX:62740 as XXXX (p2, c1, k100, u’openbkn’).
  • Saving in-memory database to /data//mosquitto.db.

there is huge amount of lines of lines like below, each time with a different port:

  • New connection from 172.30.32.2:59716 on port 1883.
  • Client closed its connection.

thanks!

Note: apparently the connection from 172.30.32.2 is the health check from the supervisor Unknown client connecting to MQTT broker · Issue #51603 · home-assistant/core · GitHub.

IMHO this is a bug, the health check should not open a new connection every time for health check, it better use a keep-alive flag to reduce overhead of creating new connections and dealing with timeouts on the broker side.

The question is, do you have ‘watchdog’ enabled in the mosquitto configuration so that it auto restarts itself in case of a crash?

I do have lots of “New client connected…” lines in the log for clients which do connect and then disconnect against connecting once and stay connected while not providing any changed information.
Perhaps you could share a complete block of lines from the log not just the lines with the identical ‘starting’ information.

The differnt ports is pretty normal if you have devices which aren’t connectied all day long but do connect, publish their topics with new values and then close their connections.

Way better but connecting once and remain connection without any new information being published.

But that won’t result in restarts.

And I bet health check isn’s something which ought to run a permant connection. You don’t want hundereds of connection being kept alive for nothing at all.

This is normal. It is not a “bug”. It is the supervisor health check.

This is probably normal too:

The rest of the log is not. Please do this:

thanks for the reply.
the idea with keep-alive is that there will be just 1 active connection for health checking, not a new connection every second (and not keeping them alive…) .

here is more info from the log between restarts (for readability, I removed valid client connections lines)

2026-01-03 13:40:01: New connection from 172.30.32.2:38194 on port 1883.
2026-01-03 13:40:01: Client <unknown> closed its connection.
[11:41:27] INFO: Service restart after closing
[13:41:28] INFO: Starting mosquitto MQTT broker...
2026-01-03 13:41:29: Warning: Mosquitto should not be run as root/administrator.
2026-01-03 13:41:29: mosquitto version 2.0.22 starting
2026-01-03 13:41:29: Config loaded from /etc/mosquitto/mosquitto.conf.
2026-01-03 13:41:29: Loading plugin: /usr/share/mosquitto/go-auth.so
2026-01-03 13:41:29:  ├── Username/password checking enabled.
2026-01-03 13:41:29:  ├── TLS-PSK checking enabled.
2026-01-03 13:41:29:  └── Extended authentication not enabled.
2026-01-03 13:41:29: Opening ipv4 listen socket on port 1883.
2026-01-03 13:41:29: Opening ipv6 listen socket on port 1883.
2026-01-03 13:41:29: Opening websockets listen socket on port 1884.
2026-01-03 13:41:29: mosquitto version 2.0.22 running
2026-01-03 13:41:31: New connection from ::1:49834 on port 1883.
2026-01-03 13:41:31: Client <unknown> disconnected due to protocol error.
2026-01-03 13:41:35: New connection from 172.30.32.1:41256 on port 1883.
2026-01-03 13:41:35: New client connected from 172.30.32.1:41256 as 3WEp9YkcDpJgD6PZ9bs95l (p2, c1, k60, u'mqtt-broker').
2026-01-03 13:41:37: New connection from 192.168.xx.xx:55362 on port 1883.
2026-01-03 13:41:37: New client connected from 192.168.xx.xx:55362 as XXXX_XXX (p2, c1, k100, u'openbkn').
[13:41:37] INFO: Successfully send discovery information to Home Assistant.
[13:41:40] INFO: Successfully send service information to the Supervisor.

... more valid client connections 

2026/01/03 13:43:27 [alert] 165#165: worker process 193 exited on signal 9
[11:43:28] INFO: Service restart after closing
[13:43:30] INFO: Starting mosquitto MQTT broker...
2026-01-03 13:43:31: Warning: Mosquitto should not be run as root/administrator.
2026-01-03 13:43:31: mosquitto version 2.0.22 starting
2026-01-03 13:43:31: Config loaded from /etc/mosquitto/mosquitto.conf.
2026-01-03 13:43:31: Loading plugin: /usr/share/mosquitto/go-auth.so
2026-01-03 13:43:31:  ├── Username/password checking enabled.
2026-01-03 13:43:31:  ├── TLS-PSK checking enabled.
2026-01-03 13:43:31:  └── Extended authentication not enabled.
2026-01-03 13:43:31: Opening ipv4 listen socket on port 1883.
2026-01-03 13:43:31: Opening ipv6 listen socket on port 1883.
2026-01-03 13:43:31: Opening websockets listen socket on port 1884.
2026-01-03 13:43:31: mosquitto version 2.0.22 running
2026-01-03 13:43:33: New connection from ::1:35090 on port 1883.
2026-01-03 13:43:33: Client <unknown> disconnected due to protocol error.
2026-01-03 13:43:37: New connection from 172.30.32.1:34410 on port 1883.
2026-01-03 13:43:37: New client connected from 172.30.32.1:34410 as 3WEp9YkcDpJgD6PZ9bs95l (p2, c1, k60, u'mqtt-broker').
[13:43:40] INFO: Successfully send discovery information to Home Assistant.

... more valid client connections 

[13:43:44] INFO: Successfully send service information to the Supervisor.
2026-01-03 13:44:01: New connection from 172.30.32.2:59842 on port 1883.
2026-01-03 13:44:01: Client <unknown> closed its connection.
[11:45:28] INFO: Service restart after closing
[13:45:30] INFO: Starting mosquitto MQTT broker...
2026-01-03 13:45:30: Warning: Mosquitto should not be run as root/administrator.
2026-01-03 13:45:30: mosquitto version 2.0.22 starting
2026-01-03 13:45:30: Config loaded from /etc/mosquitto/mosquitto.conf.
2026-01-03 13:45:30: Loading plugin: /usr/share/mosquitto/go-auth.so
2026-01-03 13:45:30:  ├── Username/password checking enabled.
2026-01-03 13:45:30:  ├── TLS-PSK checking enabled.
2026-01-03 13:45:30:  └── Extended authentication not enabled.
2026-01-03 13:45:30: Opening ipv4 listen socket on port 1883.
2026-01-03 13:45:30: Opening ipv6 listen socket on port 1883.
2026-01-03 13:45:30: Opening websockets listen socket on port 1884.
2026-01-03 13:45:30: mosquitto version 2.0.22 running
2026-01-03 13:45:33: New connection from ::1:47748 on port 1883.
2026-01-03 13:45:33: Client <unknown> disconnected due to protocol error.
2026-01-03 13:45:36: New connection from 172.30.32.1:41594 on port 1883.
2026-01-03 13:45:36: New client connected from 172.30.32.1:41594 as 3WEp9YkcDpJgD6PZ9bs95l (p2, c1, k60, u'mqtt-broker').

... more valid client connections 

[13:45:39] INFO: Successfully send discovery information to Home Assistant.

... more valid client connections 

the interesting line here is " [alert] 165#165: worker process 193 exited on signal 9" - i just want to make clear, this alert does not occur on every restart.

yes, i do :slight_smile:

I’d never turn that one as long as anything isn’t running smooth.
As you see you have no benefit from letting mosquitto restart automatically since as long as you didn’t fix the error all it does is try to restart, then stumble across the unfixed error and quits (likely this is the ‘hard kill’ (signal 9) thing followed by the restart.

Read the documentation of the plugin on how to use the optional “debug” turned on so that the log files contains some more deeper information.

Simply turn “show unused optional configuration options” in the config.
Then enable “debug” which is now visible to be set/unset.

And restart. Perhaps the log then contains some better information about what happens.

the integration was working smooth for few years already. the problem started not so long ago.

as first step, I looked at the debug log. noting interesting was there, it adds more lines related to valid connection requests, for example:

received PINGREQ from DVES_092C07
Sending PINGRESP to DVES_092C07
level=debug msg="Superuser check with backend HTTP"
level=debug msg="http request approved for mqtt-broker"
level=debug msg="superuser mqtt-broker acl authenticated with backend HTTP"
level=debug msg="setting acl cache (granted = true) for mqtt-broker"
level=debug msg="to auth record: [97 99 108 45 109 113 116 116 45 98 114 111 ...]\n

I’ll try to capture the next restart.

BTW - i’m starting to replace the tasmota/openbacken which uses mqtt to ESPHome, I find this integration it more reliable.

What are you running HA on? Perhaps you are running out of memory. What other addons are you running at same time?

A common way of debugging these things it to turn off all other addons and restart them slowly over time.

OpenBeken and ESPHome Libretiny worked good for me up until October 2024. I have just replaced my last device. Something happened around that time and since, I’m assuming from updates to the WiFi capabilities of the chips or the stacks, that made these devices, in a lack of better terms, suck!

I also suspected it’s a memory issue, but looking on memory overtime, i’m using about 80% of the 1GB on the RPI.
Currently it’s the only add-on running (i have disabled all others few weeks ago: SSH, VLC, Grafana, file-editor and NodeRed)

I think this is the log event saying it killed the addon due to running short of memory.

Time to move to a new device with more memory. In the very short term you could try increasing the swap file size to buy you time till you get a new home for HA

thanks, I’ll find a new home :slight_smile:

You have done well to last so long on 1 GB RAM. For new device I would suggest something like a second hand NUC with at least 8GB of RAM.

Sadly, with the price of memory sky-rocketing recently, memory poor systems will become more common, Raspberry Pi or NUC based.

Having a small NUC as suggested may also be affected by memory prices should you find the need to upgrade, so buy wisely with as much as you can get up front.

Before you go this route, were there any disk I/O errors showing in the system error log, indicating excessive memory page thrashing may have ‘worn’ out your drive? How much free space, (anticipating lots of log entries and dump files)?

Do you have the Visual Studio addon installed? A known memory hog.

The minimum recommended for Home Assistant is 2GB. And more if you are running lots of extra applications (add-ons).

With Raspberry Pi announcing the ‘new’, ‘budget’ 1Gb model 5 a few weeks ago, you will find many people having buyers regret and coming here for similar tales of woe.

no.

right, it’s running for few years! (it’s incredible to think how all fits into RPI3…)
probably one of the latest upgrades consumed slightly more memory that makes the broker struggling on resources.

i’ve moved many of the openbkn to esphome, once i’m done with the transition, i’ll remove the mqtt.


MQTT is very easy on resources. Running esphome addon on RPI3 is much more intensive and likely to crash RPI3 if you try to compile a binary. Better to run esphome on a separate machine( which I suspect you are doing already). It will compile much faster.

right, MQTT is very easy on resources and it was very stable for very long time.
esphome runs in docker on my PC. I’m using it only for compiling / upgrading new devices.