Error in connection to MQTT server

I am using the MQTT CLI and get this error no matter what command I use… any troubleshooting suggestions… I have the mosquito server running and the config file looks OK. Seems the connection is refused.

Traceback (most recent call last):
File “/opt/insteon-mqtt/scripts/insteon-mqtt”, line 5, in
status = insteon_mqtt.cmd_line.main()
File “/usr/lib/python3.9/site-packages/insteon_mqtt/cmd_line/main.py”, line 587, in main
return args.func(args, cfg)
File “/usr/lib/python3.9/site-packages/insteon_mqtt/cmd_line/modem.py”, line 97, in get_devices
reply = util.send(config, topic, payload, args.quiet)
File “/usr/lib/python3.9/site-packages/insteon_mqtt/cmd_line/util.py”, line 126, in send
client.connect(config[“mqtt”][“broker”], config[“mqtt”][“port”])
File “/usr/lib/python3.9/site-packages/paho/mqtt/client.py”, line 914, in connect
return self.reconnect()
File “/usr/lib/python3.9/site-packages/paho/mqtt/client.py”, line 1044, in reconnect
sock = self._create_socket_connection()
File “/usr/lib/python3.9/site-packages/paho/mqtt/client.py”, line 3685, in _create_socket_connection
return socket.create_connection(addr, timeout=self._connect_timeout, source_address=source)
File “/usr/lib/python3.9/socket.py”, line 843, in create_connection
raise err
File “/usr/lib/python3.9/socket.py”, line 831, in create_connection
sock.connect(sa)

Hey Jerryyyyyyyy

Let’s start by making sure you got mosquito set up properly

Here’s my config:

logins: []
require_certificate: false
certfile: fullchain.pem
keyfile: privkey.pem
customize:
  active: false
  folder: mosquitto

and here’s my mqtt user

and here’s the mosquito configuration but from my insteon-mqtt config.yaml:

#==========================================================================
#
# MQTT configuration
#
#==========================================================================
mqtt:
  broker: core-mosquitto
  port: 1883
  # Optional broker login data.
  username: mqttuser
  password: **********

obviously your password should match the one that you created for the user. the docs clearly state that you should NOT use the homeassistant user.

Hi,
Slow getting back…
My configuration in /config/insteon-mqtt/config.yaml is not the same… actually looks empty.
I made a mqttuser… now I better go back to wherever the mosquito thing was set up… so I did not see how to change the settings, I uninstalled it, reinstalled and then it gave me the error :

Failed to save add-on configuration, Unknown error, see supervisor logs

So then in the logs:

Disconnected from MQTT server 192.168.0.164:1883 (7)

4:27:30 PM – (WARNING) MQTT - message first occurred at 4:23:23 PM and shows up 3 times

Unable to connect to the MQTT broker: Connection Refused: not authorised.

4:27:30 PM – (ERROR) MQTT - message first occurred at 4:25:30 PM and shows up 2 times

Failed to to call /addons/core_mosquitto/restart -

4:24:49 PM – (ERROR) Home Assistant Supervisor - message first occurred at 4:24:24 PM and shows up 2 times

Timeout on /addons/core_mosquitto/options request

4:24:49 PM – (ERROR) Home Assistant Supervisor

/addons/core_mosquitto/restart return code 500

4:24:24 PM – (ERROR) Home Assistant Supervisor

Maybe better see if I can restart HA and try again… about to give up here… I have updated the system and there seems to be a new set of options for Insteon…

After restar the log:

[s6-init] making user provided files available at /var/run/s6/etc…exited 0.
[s6-init] ensuring user provided files have correct perms…exited 0.
[fix-attrs.d] applying ownership & permissions fixes…
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts…
[cont-init.d] mosquitto.sh: executing…
parse error: Expected string key before ‘:’ at line 1, column 4
[16:24:25] ERROR: Unknown HTTP error occured
jq: error (at :1): null (null) has no keys
[16:24:26] INFO: SSL is not enabled
[cont-init.d] mosquitto.sh: exited 0.
[cont-init.d] nginx.sh: executing…
[cont-init.d] nginx.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[16:24:26] INFO: Starting NGINX for authentication handling…
[16:24:27] INFO: Starting mosquitto MQTT broker…
1651793067: Warning: Mosquitto should not be run as root/administrator.
parse error: Expected string key before ‘:’ at line 1, column 4
[16:24:27] ERROR: Unknown HTTP error occured
[16:24:27] INFO: Successfully send discovery information to Home Assistant.
[16:24:27] INFO: Successfully send service information to the Supervisor.
#==========================================================================

MQTT configuration

#==========================================================================
mqtt:
broker: 127.0.0.1
port: 1883

Optional broker login data.

#username:
#password:
‘’’

Hopefully folks with mosquitto knowledge can help out here. “Mine just worked” is not a helpful response… sorry.

There’s an open bug report for this at Mosquitto broker Add-on is not initialized correctly when HA starts · Issue #2618 · home-assistant/addons · GitHub.