Mqtt no longer working after HASS update

My mqtt no longer works since the last HASS update.
I’ve uninstalled and re-installed HASS and mosquitto on the local server but just can’t get it back up and running.
The problem seems to be with the mosquitto set up as a a simple “Hello World” test in putty sometimes works but mainly comes up with an error msg:
“Error: Connection refused”

mosquitto_sub -d -u username -P password -t “dev/test”
mosquitto_pub -d -u username -P password -t “dev/test” -m “Hello world”

This is the error code I have on my Home Assistant dev page…

2017-06-28 12:58:10 ERROR (MainThread) [homeassistant.setup] Error during setup of component mqtt
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/setup.py”, line 187, in _async_setup_component
result = yield from component.async_setup(hass, processed_config)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/mqtt/init.py”, line 377, in async_setup
success = yield from hass.data[DATA_MQTT].async_connect()
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/mqtt/init.py”, line 487, in async_connect
self._mqttc.connect, self.broker, self.port, self.keepalive)
File “/usr/lib/python3.4/asyncio/futures.py”, line 388, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.4/asyncio/tasks.py”, line 286, in _wakeup
value = future.result()
File “/usr/lib/python3.4/asyncio/futures.py”, line 277, in result
raise self._exception
File “/usr/lib/python3.4/concurrent/futures/thread.py”, line 54, in run
result = self.fn(*self.args, **self.kwargs)
File “/home/homeassistant/.homeassistant/deps/paho/mqtt/client.py”, line 700, in connect
return self.reconnect()
File “/home/homeassistant/.homeassistant/deps/paho/mqtt/client.py”, line 822, in reconnect
sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
File “/usr/lib/python3.4/socket.py”, line 509, in create_connection
raise err
File “/usr/lib/python3.4/socket.py”, line 500, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

I seem to have fixed it after reading this…

still not getting any reading from my sensors or able to control switches but no more error messages and “hello world” test works in putty now

1 Like

Now you have mosquitto up and running, try restarting HA.

HA seems to give up trying to connect to the MQTT broker after start up.

thank you gpbenton
I’ve managed to solve it. while re-installing HA i’ve ended up with a new IP and have to update all my sensors/switches.
All done now and it’s back up and running.

I wont be doing an update in a hurry!!

1 Like

You need to either get your router to always use the same IP for this machine (how to do this depends on your router), or set up a static IP address. Otherwise, you are likely to get a new ip address the next time the machine is rebooted.

I do need to look into how I can assign a static address to devices. I have the same problem with some of my switches, from time to time their IP address change and I have to update by YAML file. Pain in the ass!
I’m learning as I go with this stuff, one more thing to get my head around.

my router does not support ip reservation… i know the pain when i have to update ip in yaml. whenever my router reboots/power cuts.

i wish if someone could build a component to get ip address from nmap and auto update it in yaml file.

Then you need to set up a static ip address for the computer running HA.

1 Like

i have static ip for Computer but few other devices like chromecast broadlink static ip can not be config to them.

Ah. I don’t think a component is what you need though, as that will only run after HA is running, and at that point the yaml file has already been read. It should be possible to write an ordinary python or bash script to do it outside of HA.

But I think the simplest solution is to buy a new wifi router. Any modern one should be able to do this.

i can not change the existing router it from my ISP and it uses fiber cable.

do you know the best place to get it started?

But I am sure it will have some Ethernet ports that will allow you to plug in your own Wi-Fi router.

That depends on where you are starting from - what level of knowledge you have, and what you want to learn.

doing that i have to turn off DHCP on my main router?

It depends on the capabilities of what you buy. I think most would allow you to use an external DHCP,

I seem to remember that is how I did it when I had this configuration, but that was only after a long time using the DHCP of the Wi-Fi router. I think using the ISP router’s DHCP reduced the number of networks and so looked neater, but it didn’t really have any effect on performance.