Can't connect to Mosquitto Broker

Hey@all,

I’ve just moved to HA and absolutely love it. Now I’ve tried to setup the Mosquitto broker addon, and it seems to work but I can’t connect to the mosquito server from any other host but ha itself.

I’m able to publish message over the mqtt integration but when I try to connect to the broker with a client (e.g. mqtt explorer on my mac) I get “Disconnected from server”.

The logs aren’t helpful for me. What am I missing?

Here is my addon configuration:

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

And also the logs from mosquitto:

[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... 
[01:03:15] 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.
[01:03:16] INFO: Starting NGINX for authentication handling...
[01:03:16] INFO: Starting mosquitto MQTT broker...
1641168196: mosquitto version 1.6.12 starting
1641168196: |-- *** auth-plug: startup
[01:03:17] INFO: Successfully send discovery information to Home Assistant.
[01:03:17] INFO: Successfully send service information to the Supervisor.
1641168196: Config loaded from /etc/mosquitto/mosquitto.conf.
1641168196: Loading plugin: /usr/share/mosquitto/auth-plug.so
1641168196:  ├── Username/password checking enabled.
1641168196:  ├── TLS-PSK checking enabled.
1641168196:  └── Extended authentication not enabled.
1641168196: Opening ipv4 listen socket on port 1883.
1641168196: Opening ipv6 listen socket on port 1883.
1641168196: Opening websockets listen socket on port 1884.
1641168196: Warning: Mosquitto should not be run as root/administrator.
1641168196: mosquitto version 1.6.12 running
1641168196: New connection from 127.0.0.1 on port 1883.
1641168196: Socket error on client <unknown>, disconnecting.
1641168222: New connection from 172.30.32.1 on port 1883.
{"result": "ok", "data": {}}1641168222: New client connected from 172.30.32.1 as 7sb3rNijXG2hJZWwetz4fD (p2, c1, k60, u'mqtt').
1641168383: New connection from 172.30.32.2 on port 1883.
1641168383: Socket error on client <unknown>, disconnecting.
1641168503: New connection from 172.30.32.2 on port 1883.
1641168503: Socket error on client <unknown>, disconnecting.
1641168623: New connection from 172.30.32.2 on port 1883.
1641168623: Socket error on client <unknown>, disconnecting.
1641168743: New connection from 172.30.32.2 on port 1883.
1641168743: Socket error on client <unknown>, disconnecting.
1641168863: New connection from 172.30.32.2 on port 1883.
1641168863: Socket error on client <unknown>, disconnecting.
1641168983: New connection from 172.30.32.2 on port 1883.
1641168983: Socket error on client <unknown>, disconnecting.
1641169103: New connection from 172.30.32.2 on port 1883.
1641169103: Socket error on client <unknown>, disconnecting.
1641169223: New connection from 172.30.32.2 on port 1883.
1641169223: Socket error on client <unknown>, disconnecting.
1641169343: New connection from 172.30.32.2 on port 1883.
1641169343: Socket error on client <unknown>, disconnecting.
1641169463: New connection from 172.30.32.2 on port 1883.
1641169463: Socket error on client <unknown>, disconnecting.

as well as the logs from HA:

22-01-03 01:02:59 INFO (MainThread) [supervisor.bootstrap] Seting up coresys for machine: raspberrypi4-64
22-01-03 01:02:59 INFO (SyncWorker_0) [supervisor.docker.supervisor] Attaching to Supervisor homeassistant/aarch64-hassio-supervisor with version 2021.12.2
22-01-03 01:02:59 INFO (MainThread) [supervisor.resolution.evaluate] Starting system evaluation with state CoreState.INITIALIZE
22-01-03 01:02:59 INFO (MainThread) [supervisor.resolution.evaluate] System evaluation complete
22-01-03 01:02:59 INFO (MainThread) [__main__] Setting up Supervisor
22-01-03 01:02:59 INFO (MainThread) [supervisor.api] Starting API on 172.30.32.2
22-01-03 01:02:59 INFO (MainThread) [supervisor.hardware.monitor] Started Supervisor hardware monitor
22-01-03 01:02:59 INFO (MainThread) [supervisor.dbus.manager] Load dbus interface io.hass.os
22-01-03 01:02:59 INFO (MainThread) [supervisor.dbus.manager] Load dbus interface org.freedesktop.systemd1
22-01-03 01:02:59 INFO (MainThread) [supervisor.dbus.manager] Load dbus interface org.freedesktop.login1
22-01-03 01:02:59 INFO (MainThread) [supervisor.dbus.manager] Load dbus interface org.freedesktop.hostname1
22-01-03 01:03:00 INFO (MainThread) [supervisor.dbus.manager] Load dbus interface org.freedesktop.timedate1
22-01-03 01:03:00 INFO (MainThread) [supervisor.dbus.manager] Load dbus interface org.freedesktop.NetworkManager
22-01-03 01:03:00 INFO (MainThread) [supervisor.dbus.manager] Load dbus interface de.pengutronix.rauc
22-01-03 01:03:00 INFO (MainThread) [supervisor.host.info] Updating local host information
22-01-03 01:03:00 INFO (MainThread) [supervisor.host.services] Updating service information
22-01-03 01:03:00 INFO (MainThread) [supervisor.host.network] Updating local network information
22-01-03 01:03:00 INFO (MainThread) [supervisor.host.sound] Updating PulseAudio information
22-01-03 01:03:00 INFO (MainThread) [supervisor.host.manager] Host information reload completed
22-01-03 01:03:00 INFO (MainThread) [supervisor.host.apparmor] Loading AppArmor Profiles: {'hassio-supervisor'}
22-01-03 01:03:00 INFO (SyncWorker_0) [supervisor.docker.interface] Attaching to ghcr.io/home-assistant/aarch64-hassio-cli with version 2021.09.0
22-01-03 01:03:00 INFO (MainThread) [supervisor.plugins.cli] Starting CLI plugin
22-01-03 01:03:02 INFO (SyncWorker_0) [supervisor.docker.cli] Starting CLI ghcr.io/home-assistant/aarch64-hassio-cli with version 2021.09.0 - 172.30.32.5
22-01-03 01:03:02 INFO (SyncWorker_1) [supervisor.docker.interface] Attaching to ghcr.io/home-assistant/aarch64-hassio-dns with version 2021.06.0
22-01-03 01:03:02 INFO (MainThread) [supervisor.plugins.dns] Starting CoreDNS plugin
22-01-03 01:03:03 INFO (SyncWorker_1) [supervisor.docker.dns] Starting DNS ghcr.io/home-assistant/aarch64-hassio-dns with version 2021.06.0 - 172.30.32.3
22-01-03 01:03:03 INFO (MainThread) [supervisor.plugins.dns] Updated /etc/resolv.conf
22-01-03 01:03:03 INFO (SyncWorker_0) [supervisor.docker.interface] Attaching to ghcr.io/home-assistant/aarch64-hassio-audio with version 2021.07.0
22-01-03 01:03:03 INFO (MainThread) [supervisor.plugins.audio] Starting Audio plugin
22-01-03 01:03:05 INFO (SyncWorker_0) [supervisor.docker.audio] Starting Audio ghcr.io/home-assistant/aarch64-hassio-audio with version 2021.07.0 - 172.30.32.4
22-01-03 01:03:05 INFO (SyncWorker_1) [supervisor.docker.interface] Attaching to ghcr.io/home-assistant/aarch64-hassio-observer with version 2021.10.0
22-01-03 01:03:05 INFO (SyncWorker_1) [supervisor.docker.interface] Attaching to ghcr.io/home-assistant/aarch64-hassio-multicast with version 2021.04.0
22-01-03 01:03:05 INFO (MainThread) [supervisor.plugins.multicast] Starting Multicast plugin
22-01-03 01:03:06 INFO (SyncWorker_1) [supervisor.docker.multicast] Starting Multicast ghcr.io/home-assistant/aarch64-hassio-multicast with version 2021.04.0 - Host
22-01-03 01:03:06 INFO (MainThread) [supervisor.updater] Fetching update data from https://version.home-assistant.io/stable.json
22-01-03 01:03:06 INFO (MainThread) [supervisor.homeassistant.secrets] Loaded 7 Home Assistant secrets
22-01-03 01:03:06 INFO (SyncWorker_1) [supervisor.docker.interface] Attaching to ghcr.io/home-assistant/raspberrypi4-64-homeassistant with version 2021.12.7
22-01-03 01:03:06 INFO (MainThread) [supervisor.os.manager] Detect Home Assistant Operating System 7.0 / BootSlot A
22-01-03 01:03:09 INFO (MainThread) [supervisor.store.git] Loading add-on /data/addons/core repository
22-01-03 01:03:09 INFO (MainThread) [supervisor.store.git] Loading add-on /data/addons/git/a0d7b954 repository
22-01-03 01:03:12 INFO (MainThread) [supervisor.store] Loading add-ons from store: 62 all - 62 new - 0 remove
22-01-03 01:03:12 INFO (MainThread) [supervisor.addons] Found 3 installed add-ons
22-01-03 01:03:12 INFO (SyncWorker_1) [supervisor.docker.interface] Attaching to homeassistant/aarch64-addon-mosquitto with version 6.0.1
22-01-03 01:03:12 INFO (SyncWorker_2) [supervisor.docker.interface] Attaching to ghcr.io/hassio-addons/ssh/aarch64 with version 10.0.0
22-01-03 01:03:12 INFO (SyncWorker_0) [supervisor.docker.interface] Attaching to homeassistant/aarch64-addon-configurator with version 5.3.3
22-01-03 01:03:12 INFO (MainThread) [supervisor.backups.manager] Found 0 backup files
22-01-03 01:03:12 INFO (MainThread) [supervisor.discovery] Loaded 1 messages
22-01-03 01:03:12 INFO (MainThread) [supervisor.ingress] Loaded 17 ingress sessions
22-01-03 01:03:12 INFO (MainThread) [supervisor.resolution.check] Starting system checks with state CoreState.SETUP
22-01-03 01:03:12 INFO (MainThread) [supervisor.resolution.check] System checks complete
22-01-03 01:03:12 INFO (MainThread) [supervisor.resolution.evaluate] Starting system evaluation with state CoreState.SETUP
22-01-03 01:03:12 INFO (MainThread) [supervisor.resolution.evaluate] System evaluation complete
22-01-03 01:03:12 INFO (MainThread) [supervisor.jobs] 'ResolutionFixup.run_autofix' blocked from execution, system is not running - CoreState.SETUP
22-01-03 01:03:12 INFO (MainThread) [supervisor.resolution.evaluate] Starting system evaluation with state CoreState.SETUP
22-01-03 01:03:12 INFO (MainThread) [supervisor.resolution.evaluate] System evaluation complete
22-01-03 01:03:12 INFO (MainThread) [__main__] Running Supervisor
22-01-03 01:03:12 INFO (MainThread) [supervisor.os.manager] Rauc: A - marked slot kernel.0 as good
22-01-03 01:03:12 INFO (MainThread) [supervisor.addons] Phase 'AddonStartup.INITIALIZE' starting 0 add-ons
22-01-03 01:03:12 INFO (MainThread) [supervisor.addons] Phase 'AddonStartup.SYSTEM' starting 1 add-ons
22-01-03 01:03:13 INFO (SyncWorker_3) [supervisor.docker.addon] Starting Docker add-on homeassistant/aarch64-addon-mosquitto with version 6.0.1
22-01-03 01:03:17 INFO (MainThread) [supervisor.services.modules.mqtt] Set core_mosquitto as service provider for mqtt
22-01-03 01:03:18 INFO (MainThread) [supervisor.addons] Phase 'AddonStartup.SERVICES' starting 1 add-ons
22-01-03 01:03:19 INFO (SyncWorker_0) [supervisor.docker.addon] Starting Docker add-on ghcr.io/hassio-addons/ssh/aarch64 with version 10.0.0
22-01-03 01:03:24 INFO (MainThread) [supervisor.core] Start Home Assistant Core
22-01-03 01:03:24 INFO (SyncWorker_3) [supervisor.docker.interface] Starting homeassistant
22-01-03 01:03:25 INFO (MainThread) [supervisor.homeassistant.core] Wait until Home Assistant is ready
22-01-03 01:03:38 INFO (MainThread) [supervisor.resolution.evaluate] Starting system evaluation with state CoreState.STARTUP
22-01-03 01:03:38 INFO (MainThread) [supervisor.resolution.evaluate] System evaluation complete
22-01-03 01:03:40 INFO (MainThread) [supervisor.homeassistant.api] Updated Home Assistant API token
22-01-03 01:03:42 INFO (MainThread) [supervisor.auth] Auth request from 'core_mosquitto' for 'mqtt'
22-01-03 01:03:42 INFO (MainThread) [supervisor.auth] Home Assistant not running, checking cache
22-01-03 01:04:17 INFO (MainThread) [supervisor.homeassistant.core] Detect a running Home Assistant instance
22-01-03 01:04:17 INFO (MainThread) [supervisor.addons] Phase 'AddonStartup.APPLICATION' starting 1 add-ons
22-01-03 01:04:18 INFO (SyncWorker_2) [supervisor.docker.addon] Starting Docker add-on homeassistant/aarch64-addon-configurator with version 5.3.3
22-01-03 01:04:23 INFO (MainThread) [supervisor.misc.tasks] All core tasks are scheduled
22-01-03 01:04:23 INFO (MainThread) [supervisor.core] Supervisor is up and running
22-01-03 01:04:23 INFO (MainThread) [supervisor.host.info] Updating local host information
22-01-03 01:04:23 INFO (MainThread) [supervisor.updater] Fetching update data from https://version.home-assistant.io/stable.json
22-01-03 01:04:23 INFO (MainThread) [supervisor.resolution.check] Starting system checks with state CoreState.RUNNING
22-01-03 01:04:23 INFO (MainThread) [supervisor.resolution.checks.base] Run check for IssueType.SECURITY/ContextType.CORE
22-01-03 01:04:23 INFO (MainThread) [supervisor.resolution.checks.base] Run check for IssueType.FREE_SPACE/ContextType.SYSTEM
22-01-03 01:04:23 INFO (MainThread) [supervisor.resolution.module] Create new suggestion SuggestionType.CREATE_FULL_BACKUP - ContextType.SYSTEM / None
22-01-03 01:04:23 INFO (MainThread) [supervisor.resolution.checks.base] Run check for IssueType.TRUST/ContextType.PLUGIN
22-01-03 01:04:23 INFO (MainThread) [supervisor.resolution.checks.base] Run check for IssueType.PWNED/ContextType.ADDON
22-01-03 01:04:23 INFO (MainThread) [supervisor.resolution.checks.base] Run check for IssueType.TRUST/ContextType.CORE
22-01-03 01:04:23 INFO (MainThread) [supervisor.resolution.checks.base] Run check for IssueType.TRUST/ContextType.SUPERVISOR
22-01-03 01:04:23 INFO (MainThread) [supervisor.resolution.check] System checks complete
22-01-03 01:04:23 INFO (MainThread) [supervisor.resolution.evaluate] Starting system evaluation with state CoreState.RUNNING
22-01-03 01:04:24 INFO (MainThread) [supervisor.resolution.evaluate] System evaluation complete
22-01-03 01:04:24 INFO (MainThread) [supervisor.resolution.fixup] Starting system autofix at state CoreState.RUNNING
22-01-03 01:04:24 INFO (MainThread) [supervisor.resolution.fixup] System autofix complete
22-01-03 01:04:25 INFO (MainThread) [supervisor.host.services] Updating service information
22-01-03 01:04:25 INFO (MainThread) [supervisor.host.network] Updating local network information
22-01-03 01:04:25 INFO (MainThread) [supervisor.host.sound] Updating PulseAudio information
22-01-03 01:04:25 INFO (MainThread) [supervisor.host.manager] Host information reload completed

I’ve tried to reboot HA and also the whole host but that din’t fixed the problem.

I’m running Home Assistant OS with version core-2021.12.7 on a Raspberry PI.

I hope you can help me :worried:

Double check that the sockets are defined under Network on the Configuration tab of the add-on:

Network

Container Host Description
1883/tcp 1883 Normal MQTT
1884/tcp 1884 MQTT over WebSocket
8883/tcp 8883 Normal MQTT with SSL
8884/tcp 8884 MQTT over WebSocket with SSL
1 Like

Thank you! It is definitely too late. I’ve been sitting on the configuration all day, I must have made a mistake while typing. Thanks a lot! :heart_eyes:

In my case I set the Normal MQTT Port to 1833 instead of 1883.

I have also an issue that I cannot connect to the Mosquitto Broker

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
cont-init: info: running /etc/cont-init.d/mosquitto.sh
[20:39:05] INFO: SSL is not enabled
cont-init: info: /etc/cont-init.d/mosquitto.sh exited 0
cont-init: info: running /etc/cont-init.d/nginx.sh
cont-init: info: /etc/cont-init.d/nginx.sh exited 0
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
services-up: info: copying legacy longrun mosquitto (no readiness notification)
services-up: info: copying legacy longrun nginx (no readiness notification)
s6-rc: info: service legacy-services successfully started
[20:39:05] INFO: Starting NGINX for authentication handling…
[20:39:05] INFO: Starting mosquitto MQTT broker…
2023-09-29 20:39:05: Warning: Mosquitto should not be run as root/administrator.
2023-09-29 20:39:05: mosquitto version 2.0.11 starting
2023-09-29 20:39:05: Config loaded from /etc/mosquitto/mosquitto.conf.
2023-09-29 20:39:05: Loading plugin: /usr/share/mosquitto/go-auth.so
2023-09-29 20:39:05: ├── Username/password checking enabled.
2023-09-29 20:39:05: ├── TLS-PSK checking enabled.
2023-09-29 20:39:05: └── Extended authentication not enabled.
2023-09-29 20:39:05: Opening ipv4 listen socket on port 1883.
2023-09-29 20:39:05: Opening ipv6 listen socket on port 1883.
2023-09-29 20:39:05: Opening websockets listen socket on port 1884.
2023-09-29 20:39:05: Error: Unable to create websockets listener on port 1884.
[18:39:05] WARNING: Halt add-on
s6-rc: info: service legacy-services: stopping
[18:39:06] INFO: Service restart after closing
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped

The user is created, activated and maintained in Mosquitto but when I click on devices > Mosquitto > Configuration > Re-Configure MQTT: Then the user and password is maintained correctly but when I click on ok then an error message appears: Please enter the connection information of your MQTT broker. Connection failed.

The network ports are correct too.

Can anyone help me please?

1 Like