MQTT integration stopped working

After upgrading to from 0.98.2 to 0.98.4 my MQTT integration has stopped working for some reason. Downgrading back to 0.98.2 or upgrading to 0.98.5 has not solved the problem.

I’m running eclipse-mosquitto with no security in a docker container and connecting to it and publishing events from other sources has no issues.


  broker: localhost (also tried with direct container ip and host ip)
  port: 1883
  discovery: false


2019-09-11 15:24:24 ERROR (MainThread) [homeassistant.components.mqtt] Failed to connect due to exception: [Errno 98] Address in use
2019-09-11 15:24:24 WARNING (MainThread) [homeassistant.config_entries] Config entry for mqtt not ready yet. Retrying in 5 seconds.
2019-09-11 15:24:26 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/", line 406, in _async_add_entity
    await entity.async_added_to_hass()
  File "/usr/src/homeassistant/homeassistant/components/mqtt/", line 132, in async_added_to_hass
    await self._subscribe_topics()
  File "/usr/src/homeassistant/homeassistant/components/mqtt/", line 199, in _subscribe_topics
    "qos": self._config[CONF_QOS],
  File "/usr/src/homeassistant/homeassistant/components/mqtt/", line 82, in async_subscribe_topics
    await requested.resubscribe_if_necessary(hass, current)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/", line 39, in resubscribe_if_necessary
    hass, self.topic, self.message_callback, self.qos, self.encoding
  File "/usr/src/homeassistant/homeassistant/components/mqtt/", line 452, in async_subscribe
  File "/usr/src/homeassistant/homeassistant/components/mqtt/", line 848, in async_subscribe
    await self._async_perform_subscription(topic, qos)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/", line 884, in _async_perform_subscription
  File "/usr/src/homeassistant/homeassistant/components/mqtt/", line 984, in _raise_on_error
    "Error talking to MQTT: {}".format(mqtt.error_string(result_code))
homeassistant.exceptions.HomeAssistantError: Error talking to MQTT: The client is not currently connected.

I’m also running owntracks, however I’ve tried to disable it with no effect. I’ve also tried removing the configuration.yaml entry and doing it through integrations, however i get message “Unable to connect to the broker” in the configuration interface.

As you can see from the config I’m not running the embedded MQTT server, so the “Address in use” message makes no sense. Looking at the mosquitto logfile I see no connection attempt from HA. I’ve attempted a wget localhost:1883 from the HA container to see if I can reach the mosquitto container and the mosquitto.log indicates that I can reach the container, so that’s not the issue.

I’ve run out of ideas to try, any suggestions?

Have you tried to set up a client id?
I’ve had issues in the past so I now hard code a client id per machine/device and since then no issues.

Yup, tried that. :slight_smile:

Have you tried removing the mqtt section of your configuration.yaml and setting up MQTT via the Integrations section of HA? (The way you have set it up now is deprecated:

Yup, tried every combination of configuration.yaml, Integrations and Owntracks I could think of.

I even made sure to remove entries from .storage/core.config_entries to make sure.

The problem when I try to add it from the Integrations page is that it says it cannot connect to the broker. It is not possible to connect another MQTT from Integrations when it is configured in configuration.yaml.

not sure if it’ll help, but worth a try?
Is your HA also running in a container? Have you tried to set a dependence to the MQTT container?
In docker-compose i’ve done this for other containers:

      container_name: ha
      image: homeassistant/home-assistant:0.98.4
        - /home/cctv/docker_ha:/config
        - /etc/localtime:/etc/localtime:ro
        - /home/cctv/docker_ha/shell_scripts:/shell_scripts:ro
        - /dev/serial/by-id/usb-RFXCOM_RFXtrx433_A1XETWB5-if00-port0:/dev/serial/by-id/usb-RFXCOM_RFXtrx433_A1XETWB5-if00-port0
        - influxdb
        - zigbee2mqtt
      restart: always
      network_mode: host

I’m not using compose, but I have checked that I can actually connect to mosquitto from the HA container, and that works.

I’ve done a bit of a dive into the code and it seems that the error is being thrown by line 805 in

This again is caused in line 1000 in

Further back than that I’ve not been able to trace it.