[homeassistant.components.mqtt] Failed to connect due to exception: [Errno 111] Connection refused

Hi,

I install mosquitto because I want to use mqtt with shelly. I think I have a problem.
u.
In the log I read [homeassistant.components.mqtt] Failed to connect due to exception: [Errno 111] Connection refused . I found in the forum that can be if the username or password is incorrect but I check several times.
This is the part in my configuration.yaml

mqtt:
  broker: 192.168.86.32
  port: 1883
  client_id: home-assistant-1
  username: !secret mqtt_user
  password: !secret mqtt_pass
  discovery: true

This is the service status:

pi@raspberrypi:/home/homeassistant/.homeassistant $ sudo /etc/init.d/mosquitto status
● mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
Loaded: loaded (/etc/init.d/mosquitto; generated; vendor preset: enabled)
Active: active (exited) since Sat 2019-02-09 14:06:11 CET; 18min ago
Docs: man:systemd-sysv-generator(8)
Process: 290 ExecStart=/etc/init.d/mosquitto start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/mosquitto.service

feb 09 14:06:08 raspberrypi systemd[1]: Starting LSB: mosquitto MQTT v3.1 me……
feb 09 14:06:11 raspberrypi mosquitto[290]: Starting network daemon:: mosquitto.
feb 09 14:06:11 raspberrypi systemd[1]: Started LSB: mosquitto MQTT v3.1 mes…er.
Hint: Some lines were ellipsized, use -l to show in full.

And this is the log:
2019-02-09 14:12:10 ERROR (MainThread) [homeassistant.components.mqtt] Failed to connect due to exception: [Errno 111] Connection refused
2019-02-09 14:12:16 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to shellies/shelly-1/roller/0
2019-02-09 14:12:16 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
result = coro.send(None)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py”, line 350, in _async_add_entity
await entity.async_added_to_hass()
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/mqtt/cover.py”, line 187, in async_added_to_hass
await self._subscribe_topics()
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/mqtt/cover.py”, line 287, in _subscribe_topics
topics)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/mqtt/subscription.py”, line 83, in async_subscribe_topics
await requested.resubscribe_if_necessary(hass, current)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/mqtt/subscription.py”, line 44, in resubscribe_if_necessary
self.qos, self.encoding
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/mqtt/init.py”, line 319, in async_subscribe
qos, encoding)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/mqtt/init.py”, line 701, in async_subscribe
await self._async_perform_subscription(topic, qos)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/mqtt/init.py”, line 736, in _async_perform_subscription
_raise_on_error(result)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/mqtt/init.py”, line 821, 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.
2019-02-09 14:12:26 WARNING (MainThread) [homeassistant.components.switch] Setup of platform broadlink is taking over 10 seconds.
2019-02-09 14:12:28 ERROR (Thread-16) [homeassistant.components.switch.broadlink] Failed to connect to device

Can someone help me?

Thank you.

Hi,

I try to use also the mqtt home assistant integrated service, I have no error, but the system don’t work. I don’t receive the state of the cover and if I click the command the cover don’t receive the command.

Thank you.

2019-02-10 09:50:17 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to shellies/shelly-1/roller/0
2019-02-10 09:50:26 WARNING (MainThread) [homeassistant.components.switch] Setup of platform broadlink is taking over 10 seconds.
2019-02-10 09:50:28 ERROR (Thread-16) [homeassistant.components.switch.broadlink] Failed to connect to device
2019-02-10 09:56:25 DEBUG (MainThread) [homeassistant.components.mqtt] Transmitting message on shellies/shelly-1/roller/0/command: closeSchermata%20del%202019-02-10%2009-56-17

Hi to everyone,
finnaly today I solve something.
If I use this command:
mosquitto -d
in the raspberry I’m able to command the relay.
But I have some problem:

  1. every time that I reboot my raspberry if I don’t use the command mosquitto -d I’m not able to command shelly.
  2. the state is always unknow. Is trange because if I use the sub command of mosquitto in the channelthere is a transmission of information:
    Client mosqsub/11824-raspberry sending CONNECT
    Client mosqsub/11824-raspberry received CONNACK
    Client mosqsub/11824-raspberry sending SUBSCRIBE (Mid: 1, Topic: shellies/shellyswitch-55C520/roller/0, QoS: 0)
    Client mosqsub/11824-raspberry received SUBACK
    Subscribed (mid: 1): 0
    Client mosqsub/11824-raspberry received PUBLISH (d0, q0, r0, m0, ‘shellies/shellyswitch-55C520/roller/0’, … (4 bytes))
    stop

Any suggestion?

Thank you

1 Like

Hi, I upgraded to 0.99.2 today and HA could no longer connect to Mosquitto. All my MQTT sensors stopped working. I never had this problem before. When I used the command mosquitto -d as suggested in your post, HA was able to connect to Mosquitto/MQTT again and all are working now.
What’s the explanation for this?

Hi,
I have the same problem with mqtt broker, means: connectio refused.

[core-ssh solarman]$ mosquitto_pub -h 192.168.100.110 -t homeassistant/switch/1/on -m "Switch is ON" 
Connection error: Connection Refused: not authorised.
Error: The connection was refused.

my mqtt broker is working well, config is:

active: true
folder: mosquitto
anonymous: true
customize:
  active: true
  folder: mosquitto
certfile: fullchain.pem
keyfile: privkey.pem
require_certificate: false

My HA IP is 192.168.100.110

If using the add-on, that does no longer work.