Error returned from MQTT server: The connection was lost

Seem to have lost all of my mqtt devices and I have no idea why.

I see this in the log:

Logger: homeassistant.components.mqtt.client
Source: components/mqtt/client.py:1229
integration: MQTT (documentation, issues)
First occurred: 10:07:30 PM (1 occurrence)
Last logged: 10:07:30 PM

Error returned from MQTT server: The connection was lost.

Haven’t (at least knowingly) changed anything. Looks like the integration has lost connection with the broker, but I cannot see why.

I am using EMQX as the broker (the home assistant add on one). I applied the latest update to version 0.8.0 thinking it might help. Can’t see anything in EMQX that stands out, logs are good, add on is up and running.

I’ve reloaded the integration, restarted zigbee to MQTT, EMQX, rebooted home assistant. Am at a bit of a loss as to why this has happened or what to look for.

Also reconfigured the integration to change to a new user name and password can can see that user as logged in in EMQX.

Grateful for any pointers.

Further errors:

Logger: homeassistant.helpers.translation
Source: helpers/translation.py:226
First occurred: 10:55:32 PM (1 occurrence)
Last logged: 10:55:32 PM

Failed to load integration for translation: Integration 'MQTT' not found.
Logger: homeassistant.components.mqtt.util
Source: components/mqtt/util.py:78
integration: MQTT (documentation, issues)
First occurred: 10:58:55 PM (1 occurrence)
Last logged: 10:58:55 PM

Error talking to MQTT: The client is not currently connected.
Logger: homeassistant
Source: components/mqtt/client.py:1274
First occurred: 10:59:00 PM (1 occurrence)
Last logged: 10:59:00 PM

Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/client.py", line 999, in _async_resubscribe_and_publish_birth_message
    await self.async_publish(
    ...<4 lines>...
    )
  File "/usr/src/homeassistant/homeassistant/components/mqtt/client.py", line 662, in async_publish
    await self._async_wait_for_mid_or_raise(msg_info.mid, msg_info.rc)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/client.py", line 1274, in _async_wait_for_mid_or_raise
    raise HomeAssistantError(
    ...<5 lines>...
    )
homeassistant.exceptions.HomeAssistantError: Error talking to MQTT: The client is not currently connected.

Check if you have yaml config for MQTT. Make sure it’s in lowercase. Someone on reddit had your same issue and it turned out it was because they used MQTT instead of mqtt in the yaml.

Thanks for that, it’s given me something to work on. I was modifying configuration,yaml around that time to configure irrigation unlimited so perhaps I deleted something in error.

I set up the mqtt integration via the UI, so I don’t remember a yaml config for MQTT. Could you give me a little more information on that? Should there be something in configuration.yaml or a different yaml file somewhere?

If you set up mqtt in the UI and are relying on autodiscovery (your Z2M & other mqtt devices show up by themselves), then you probably don’t have anything in your yaml files.

If your irrigation unlimited (or anything else)needs mqtt defined in yaml, then forget everything I said in the previous paragraph. Search all your yaml files (not just configuration.yaml) & double check mqtt is in lowercase.

Alternatively, restore an old backup from before your changes and redo the integration setup

Can’t see anything in the irrigation.yaml that references mqtt at all.

Without seeing your yaml files or knowing what you changed, it’s gonna be hard to help you.

Run a configuration check in developer tools. If that doesn’t flag anything, then it’s easier to restore a backup. You’ve been making regular backups, right?

Yeah, I’ve run the check configuration in developer tools… no issues. Been looking though my yaml config files in the config folder, nothing leaps out. I’ve been backing up via the nabu casa subscription so I guess restoring might be the next step. At a complete loss as to why this has happened.

You might as well forget about restoring a backup then. Nabu casa only stores 1 backup - if the last automated backup occurred after your latest changes, then the backup will be identical to your current config.

Do you have any manual or local backups from before your changes available?

Yeah, I have configured the backups to store locally as well as through nabu-casa cloud. So I have three automatic backups to choose from, looking at once created October 25, 2025 at 4:52 AM. Do you think I should restore Home Assistant only or go include all the addons as well?

Unless you mucked around with the emqx & Z2M settings recently, you don’t need to restore the addons.

Why don’t you download the backup to your PC & compare each yaml file to your current config before you attempt a restore? You can find diff checkers online or use notepad++ to compare.
It’ll take more time, but it should make it pretty easy to narrow down the culprit before needing to do a restore.

Edit:

Hang on. Oct 25 is this morning. You’ll need something older if the changes weren’t applied today.

If you have the File Editor or Studio Code Server installed, you should be able to find a “configuration.yaml” file in a HomeAssistant/zigbee2mqtt folder (created by the Z2M add-on integration).

It’s the 26th where I am. I downloaded the backup and can see the changes I made last night do not appear in the configuration.yaml file in the backup. Mind you, I don’t see anything in either configuration.yaml file that looks suspect.

Look at all the !include lines in your yaml. You need to check those included files too.

yeah, checked that as well… no issue that I can see. z2m is working fine. I can see and operate the sensors and devices through the z2m addon.

homeassistant:
  enabled: true
  legacy_action_sensor: false
  experimental_event_entities: false
advanced:
  network_key:
    - 57
    - 233
    - 123
    - 119
    - 69
    - 63
    - 147
    - 164
    - 93
    - 71
    - 127
    - 180
    - 65
    - 81
    - 254
    - 53
  pan_id: 14071
  ext_pan_id:
    - 155
    - 202
    - 135
    - 212
    - 101
    - 41
    - 136
    - 161
mqtt:
  base_topic: zigbee2mqtt
  server: mqtt://homeassistantonmac:1883
  user: grasshopper
  password: [password is here but removed for this post]
frontend:
  enabled: true
  port: 8099
serial:
  rtscts: false
  port: tcp://192.168.1.160:6638
  adapter: zstack
  baudrate: 115200
device_options: {}
devices:
  '0x00158d000483b93d':
    friendly_name: 3D Printer
    description: Vibration Sensor
  '0x54ef4410007bab19':
    friendly_name: Smart Dimmer H1
    description: Aqara Smart Dimmer H1
    legacy: false
  '0x00158d000635a435':
    friendly_name: Leak Sensor Kitchen
    description: Aqara Leak Sensor
  '0x00158d00091ea906':
    friendly_name: Door Front
    description: Aqara door and window sensor
  '0x00158d000949a107':
    friendly_name: Spare Room Environment
    description: Aqara temperature, humidity and pressure sensor.
  '0x54ef44100065d497':
    friendly_name: Luminance Kitchen
    description: Aqara Luminance Sensor
  '0x54ef441000762cad':
    friendly_name: Bedroom Presence
  '0x00158d000462c817':
    friendly_name: Motion Laundry
  '0x00158d0002e33aeb':
    friendly_name: Smart Switch Living Room
    legacy: false
  '0x00158d000588aea1':
    friendly_name: Smoke Downstairs
  '0x001788010dd0e54b':
    friendly_name: Tap Dial Switch
  '0x00158d0009ee650a':
    friendly_name: Leak Sensor Bathroom
  '0x680ae2fffe3df5e6':
    friendly_name: IKEA Sound Controller
    legacy: false
  '0x0ceff6fffe56196a':
    friendly_name: Blind Bedroom
  '0xe8e07efffe4adb07':
    friendly_name: Blind Front
  '0x00158d0002f24a2f':
    friendly_name: Smart Switch Bedroom
  '0x583bc2fffe928b19':
    friendly_name: Blind Side Back
  '0x583bc2fffe928169':
    friendly_name: Blind Side Front
  '0x583bc2fffe908651':
    friendly_name: Blind Kitchen
  '0xa4c138518145dcb9':
    friendly_name: Curtain Balcony
    invert_cover: true
  '0xa4c138ac312f1d61':
    friendly_name: Powerboard Zigbee
  '0xa4c138e940aa2d75':
    friendly_name: Curtain Bedroom
  '0x00158d00091eaa34':
    friendly_name: Window Kitchen
  '0x00158d00091eaa70':
    friendly_name: Window Bedroom
  '0x04cf8cdf3c772304':
    friendly_name: '0x04cf8cdf3c772304'
  '0x00158d0007ede3c2':
    friendly_name: Smart Switch Kitchen
  '0xa4c13885212944eb':
    friendly_name: Mac Mini Power
availability:
  enabled: true
version: 4

Thanks…

Looked through all of these, don’t see a reference to mqtt or MQTT in any of them…

homeassistant:
  packages:
    irrigation: !include irrigation.yaml

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
notify: !include notify.yaml
template: !include template.yaml

I’m all out of ideas. Only thing I can spot is server: mqtt://homeassistantonmac:1883 which might not match your emqx settings.

If you didn’t recently modify that part, now would be the time to do a restore from before your changes

Think the server address checks out… this is from the EMQX addon log:

EMQX_NODE__NAME [node.name]: [email protected]

I can see the client is connected from within EMQX:

z2m should be the second client on the list (logged in as grasshopper);
homeassistant should be the last on the list.

I think I’ll uninstall the MQTT integration and re-install it to see if that helps. Think I’ll also change the broker login usernames to better reflect where they are logging in from (ie change the grasshopper username to zigbee2mqtt for example).

I deleted all the users from within EMQX and re-added them one by one. Seems to have resolved the issue for reasons I cannot explain!

Just gotta get parking assist back, but that’s a minor consideration I can get to later.

Thanks for everyone that chimed in with assistance, its very much appreciated.

This would give me ZERO trust in that add-on, and convince me to load the one in Official Add-ons running Mosquitto.

1 Like

Yeah, something to think about. Thought I’d give EMQX a try as I thought it would offer more information for troubleshooting.