MQTT (independent server) keeps disconnecting

Hello Community,

so for the past week I’ve been suddenly having problems with mqtt connection. Some facts first:
I run two HA Instances on seperate servers
I connect them via MQTT
The MQTT Broker is NOT the integration, it’s running on the same server as HA Instance 1.
The problem only appears in HA Instance 2
The MQTT Server has a public IP and a stable connection, I revieve all Sensor data via it, it doesn’T disconnect at all.
I have no user set up for my independent broker (because we are still evaluating everything)
I tried installing the second Instance on the same server as the first instance and the mqtt broker just to be exclude the possiblity of connection issues between the two servers: no changes at all, same problem.

I didn’t really do anything that would cause this, I neither installed an add-on or uninstalled one, I did update but setting nback the updates didn’t change anything. I deactivated all scripts and automations that include MQTT Publish and switched my MQTT Switches and Selects manually, same Problem.
The message just get’s lost somewhere because the connection in Instance 2 keeps breaking.

I know the picture say “Reset by peer” but this is pretty confusing to me, I do have MQTT Device Integration installed (The client) but there is no setting for allowed connection time. I’m at a loss here, I even set the whole thing up from scratch again and still the Problem presists. I thought it would be the Selects and Switches but those I have on the first instance too and they cause no problem at all there.
Any ideas?


So I’m still trying to find the solution but I found that the problem isn’t witht he publishing, the problem happens when the instance is trying to recieve a message from a subscribed topic. Still no idea why.

I am not sure why, if my solution works, it would suddenly have given problems, it should have always performed poorly, but here goes anyway. It may be, (and I am no expert) you are trying to bind the same port on the MQTT server machine, to two different IP address’s using same port #. This is not easily done. Try this: Set your first HA instance to connect to MQTT Server using IP Address like, and the second HA instance to use (change the IP’s to match your network). Then on the machine hosting MQTT Broker in /etc/mosquitto/conf.d , make a file ending in .conf and add the lines:

listener 12883

listener 1883

Restart the broker, restart both HA’s and see if that helps. This is from top of my head, so you may need to check config’s for your device. Good luck.

Thank you for the hint, I changed that but sadly it’s still the same issue. It still keeps breaking off.

I found at least a way to keep the connection on longer so it wouldn’t break off after only 10 seconds and I found that the publishing seems to be working just fine now I’ve done this but the recieving is causing most the problems.

I see the error message says the MQTT reset was on port 1883, is that the port for the second HA you were having trouble with? Is this error message from the second HA or the first one? It makes sense that the publish works because it just sends a network broadcast, I don’t think it requires a specific tcp bind, its when you want the broker to receive from a specific device you need the tcp port bind. Can you share the MQTT config from both HA’s?
Have you looked at


after it disconnects, check both machines. Does the network connection stay up when it fails?

Yep the problem instance is on 1883 now.

Not sure what dmesg is, google say it’s linux command? How do I access it? I can’t see anything indicating the network connection is breaking.

I mean there really isn’t much to the config, it’s configurated via the Integration.
There is the IP, the Port, The user and the Password and not the keepalive in the config set to 60.
That’s it. Otherwise they are set up completly the same so I don’t understand why the one instance works and the other doesn’t

I thought it might be because for my selects and switches command topic and state topic are the same but that’s not it either, it behaves like this with any mqtt sensor.

I just found this in my logs after setting everything to debug
“2022-03-29 18:16:04 DEBUG (MainThread) [zeroconf] IPv6 scope_id 0 associated to the receiving interface”
could this be related?

Do you by chance have the same user and password for both HA instances, MQTT broker may not like that, something to try. It expects different client_id for each connection.
For dmesg, just run it in a terminal, type it in and enter, on the server you may need to run sudo dmesg. Note: there could be lots of stuff in there, beware of rabbit holes…

I do actually have the same user set up, I’ll try giving it another user but client id is differnt.

I just tried the dsmeg…rabbit hole indeed I need time to check that out, there are about 500 lines there.

Okay so regarding the dmesg commans, nothing changes before or after disconnection.

So I kinda gave up and just set up my HA Instance from scratch. I didn’t use a back up but I did copy the config file and some otherfiles. Otheriwse I did a clean install oneverything else.
So far it’s been working but I need to check if this is gonna happen again over time. Wish me luck.

1 Like