[Solved] Zigbee2mqtt : unable to connect

Hi all

I just setup Home Assistant in Docker with Compose and Portainer, i hope it went all good ( I think so ) to the last part setting up zigbee2mqtt

I Iframed zigbee2mqtt and portainter to Home Assistant

When i open zigbee2mqtt in Home Assistant it says “unable to connect”

When i look at the log in Portainer for zigbee2mqtt it says

"YAMLException: bad indentation of a mapping entry (14:4)"
 11 |   # MQTT server URL
 12 |   "server: 'mqtt://192.168.50.131'
 13 |   # MQTT server authentication, un ...
 14 |    "user: mqtt_user"
---------^
 15 |    password: *******
 16 | 
    at generateError (/app/node_modules/js-yaml/lib/loader.js:183:10)
    at throwError (/app/node_modules/js-yaml/lib/loader.js:187:9)
    at readBlockMapping (/app/node_modules/js-yaml/lib/loader.js:1182:7)
    at composeNode (/app/node_modules/js-yaml/lib/loader.js:1441:12)
    at readBlockMapping (/app/node_modules/js-yaml/lib/loader.js:1164:11)
    at composeNode (/app/node_modules/js-yaml/lib/loader.js:1441:12)
    at readDocument (/app/node_modules/js-yaml/lib/loader.js:1625:3)
    at loadDocuments (/app/node_modules/js-yaml/lib/loader.js:1688:5)
    at Object.load (/app/node_modules/js-yaml/lib/loader.js:1714:19)
    at Object.read (/app/lib/util/yaml.ts:7:21)
"Using '/app/data' as data directory"
"/app/node_modules/js-yaml/lib/loader.js:183"
"  return new YAMLException(message, mark);"

I am not sure but i looks like a user issue ?

Home Assistant can see the USB zigbee controller

I am not getting any error in the rest of my logs


"This is my configuration.yaml for zigbee2mqtt"

# Home Assistant integration (MQTT discovery)
homeassistant: true

# allow new devices to join
permit_join: true

# MQTT settings
mqtt:
  # MQTT base topic for zigbee2mqtt MQTT messages
  base_topic: zigbee2mqtt
  # MQTT server URL
  server: 'mqtt://192.168.50.131'
  # MQTT server authentication, uncomment if required:
     user: mqtt_user
     password: *********

# Serial settings
serial:
  # Location of CC2531 USB sniffer
  port: /dev/ttyACM0

And this is my docker-compose.yaml

version: '3.0'

services:
  portainer:
    container_name: portainer
    image: portainer/portainer-ce
    devices:
     -  /dev/ttyACM0:/dev/ttyACM0
    restart: always
    ports:
      - "9000:9000/tcp"
    environment:
      - TZ=Europe/Copenhagen
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /opt/portainer:/data

  homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:stable"
    volumes:
      - /opt/homeassistant/config:/config
      - /etc/localtime:/etc/localtime:ro
     devices:
     -  /dev/ttyACM0:/dev/ttyACM0
    restart: unless-stopped
    privileged: true
    network_mode: host

  mosquitto:
    image: eclipse-mosquitto
    container_name: mosquitto
    volumes:
      - /opt/mosquitto:/mosquitto
      - /opt/mosquitto/data:/mosquitto/data
      - /opt/mosquitto/log:/mosquitto/log
    ports:
      - 1883:1883
      - 9001:9001

  zigbee2mqtt:
    container_name: zigbee2mqtt
    image: koenkk/zigbee2mqtt
    restart: unless-stopped
    volumes:
      - /opt/zigbee2mqtt/data/data:/app/data
      - /run/udev:/run/udev:ro
    ports:
      # Frontend port
      - 8080:8080
    environment:
      - TZ=Europe/Copenhagen
    devices:
      - /dev/ttyACM0:/dev/ttyACM0

And this is my Home Assistant configuration.yaml

# Add panel to HomeAss
panel_iframe:
  portainer:
    title: "Portainer"
    url: "http://192.168.50.131:9000/#/containers"
    icon: mdi:docker
    require_admin: true
  zigbee2mqtt:
    title: "zigbee2mqtt"
    url: "http://192.168.50.131:8080"
    icon: mdi:zigbee
    require_admin: true

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

I am not sure but i looks like a user issue ? Home Assistant can see the USB zigbee controller

I am not getting any error in the rest of my logs

Can someone point me in a direction of a solution :slight_smile:
Edit : tried to clean the post up

Have you found out how

Welcome!

You have to do a bit of homework on how to format your configuration and code files so they represent what you are seeing on your computers when you post them here on the forum.

The fundamental construct to use is a pair of triple 'back quotes : ``` ’ and your code in between:

user@docker-01:~/zigbee2mqtt/zigbee2mqtt-data$ cat configuration.yaml
permit_join: false
mqtt:
  base_topic: zigbee2mqtt
  server: mqtt://192.168.2.242
serial:
  port: /dev/serial/by-id/usb-1a86_TubesZB_971207DO-if00-port0
frontend:
  port: 8080

Good hunting!

2 Likes

Well, maybe you should read the error message. It’s all there:

Password and username are part of the mqtt: part, so they have to be indented with two spaces.

mqtt:
  user: username
  password: password
1 Like

Thank you for heads up :slight_smile:

Thanks i will try that out after dinner :slight_smile:

Okey now i manged to get the

“YAMLException: bad indentation of a mapping entry (14:4)”

fixed :slight_smile:

But now the log goes

Zigbee2MQTT:info  2023-11-08 15:09:25: Logging to console and directory: '/app/data/log/2023-11-08.15-09-25' filename: log.txt

Zigbee2MQTT:info  2023-11-08 15:09:25: Starting Zigbee2MQTT version 1.33.2 (commit #9996c93)

Zigbee2MQTT:info  2023-11-08 15:09:25: Starting zigbee-herdsman (0.21.0)

Zigbee2MQTT:info  2023-11-08 15:09:29: zigbee-herdsman started (resumed)

Zigbee2MQTT:info  2023-11-08 15:09:29: Coordinator firmware version: '{"meta":{"maintrel":"3 ","majorrel":"6","minorrel":"10","product":8,"revision":"6.10.3.0 build 297"},"type":"EZSP v8"}'

Zigbee2MQTT:info  2023-11-08 15:09:29: Currently 0 devices are joined:

Zigbee2MQTT:info  2023-11-08 15:09:29: Zigbee: disabling joining new devices.

Zigbee2MQTT:info  2023-11-08 15:09:29: Connecting to MQTT server at mqtt://localhost

Zigbee2MQTT:error 2023-11-08 15:09:29: MQTT error: connect ECONNREFUSED 127.0.0.1:1883

Zigbee2MQTT:error 2023-11-08 15:09:29: MQTT failed to connect, exiting...

Zigbee2MQTT:info  2023-11-08 15:09:29: Stopping zigbee-herdsman...

Zigbee2MQTT:info  2023-11-08 15:09:29: Stopped zigbee-herdsman

Using '/app/data' as data directory 

i saw on github someone recomend setting the

mqtt:
  server: 'mqtt://192.168.50.131'

to

mqtt:
  server: 'mqtt://172.17.0.4:1883' 

or

mqtt:
  server: 'mqtt://172.17.0.4'

None of the did the trick for me

then i seen someone add

adapter: ezsp
advanced:
  network_key: GENERATE
frontend: true

I havent tested that since i am not sure about the adapter name

i amsue my issue is

Zigbee2MQTT:error 2023-11-08 15:09:29: MQTT error: connect ECONNREFUSED 127.0.0.1:1883

and the 127.0.0.1:1883 should be the ip of the zigbee2mqtt docker or ?
172.17.0.4 is the IP of my zigbee2mqtt docker
Looking once again for a hint in the right direction :slight_smile:

You are going to have to share how you installed your MQTT broker, I do not see this info in your posts. Take that back, I do see your docker config:

  mosquitto:
    image: eclipse-mosquitto
    container_name: mosquitto
    volumes:
      - /opt/mosquitto:/mosquitto
      - /opt/mosquitto/data:/mosquitto/data
      - /opt/mosquitto/log:/mosquitto/log
    ports:
      - 1883:1883
      - 9001:9001

Have a look at the mosquitto logs either via docker or in your host, I think the log file is at :

/opt/mosquitto/log

I’m not sure if the single quote ’ is necessary or causing issues in the Zigbee2MQTT configuration.yaml

mqtt:
  server: 'mqtt://192.168.50.131'

If that is correct IP address and there is nothing on your host machine blocking the ports used by MQTT broker, 1883 and 9001, you should be able to connect to the MQTT broker with tool below.

The tool, MQTT explorer (link below) is a good tool to have in your quiver. It lets you see and publish MQTT messages to your MQTT broker.

1 Like

Tanks for the reply

the logs says

No log line matching the '' filter

In portianer container log

I will have a look at the tool :slight_smile:

nuc@nucbox:/opt/zigbee2mqtt/data/data$ netstat -na | grep 1883
tcp        0      0 0.0.0.0:1883            0.0.0.0:*               LISTEN     
tcp        0      0 192.168.50.131:58027    192.168.50.131:1883     ESTABLISHED
tcp6       0      0 :::1883                 :::*                    LISTEN     
nuc@nucbox:/opt/zigbee2mqtt/data/data$ netstat -na | grep 9001
tcp        0      0 0.0.0.0:9001            0.0.0.0:*               LISTEN     
tcp6       0      0 :::9001                 :::*                    LISTEN     
unix  3      [ ]         STREAM     CONNECTED     339001   

Does this give the answer for the ports ?

When i did the setup of MQTT in ended with this

Not clear from your posts what you have. First picture of your netstat does seem to indicate that something is connected to ‘something’ on port 1883 at ip 192.168.50.131. That could be your Home Assistant instance that you show a picture of in your second post. I’m not a netstat guru by any means, so just guessing.

You might try using:

docker ps

to get the id of the mosquitto container and the do a:

docker logs

docker inspect

docker container port

might show you some useful info about the mosquitto container.

I’m not sure if understand where your mosquitto.conf file is located:

https://hub.docker.com/_/eclipse-mosquitto

but you might want to change some of the setting there to get a more complete log of connections and disconnections, for example:

#
# https://mosquitto.org/man/mosquitto-conf-5.html
listener 1883
allow_anonymous true
log_timestamp_format %Y-%m-%dT%H:%M:%S
connection_messages true
log_type subscribe
log_type unsubscribe
log_type websockets
log_type error
log_type warning
log_type notice
log_type information
persistence true
persistence_location /mosquitto/config/
log_dest file /mosquitto/config/m.log
1 Like

OK here is what i got

nuc@nucbox:/opt$ docker ps
CONTAINER ID   IMAGE                                          COMMAND                  CREATED        STATUS                                  PORTS                                                                                  NAMES
caa50c79ca2e   koenkk/zigbee2mqtt                             "docker-entrypoint.s…"   9 hours ago    Restarting (1) Less than a second ago                                                                                          zigbee2mqtt
4d0a9d742a3c   eclipse-mosquitto                              "/docker-entrypoint.…"   10 hours ago   Up 6 hours                              0.0.0.0:1883->1883/tcp, :::1883->1883/tcp, 0.0.0.0:9001->9001/tcp, :::9001->9001/tcp   mosquitto
cb8608481ba6   ghcr.io/home-assistant/home-assistant:stable   "/init"                  12 hours ago   Up 6 hours                                                                                                                     homeassistant
c3dd5072efb4   portainer/portainer-ce                         "/portainer"             12 hours ago   Up 12 hours                             8000/tcp, 9443/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp                          portainer

and

nuc@nucbox:/opt$ docker container port 4d0a9d742a3c
1883/tcp -> 0.0.0.0:1883
1883/tcp -> [::]:1883
9001/tcp -> 0.0.0.0:9001
9001/tcp -> [::]:9001

docker logs does not show anything

nuc@nucbox:/opt$ docker logs 4d0a9d742a3c
nuc@nucbox:/opt$ 

the docker inspect is alot of info and bugs me out when i try to post it … will figure it out
I will edit the mosquitto.conf for the extra log info

uc@nucbox:/opt$ docker inspect 4d0a9d742a3c
[
    {
        "Id": "4d0a9d742a3c5c7fab0a1472ac4e4f239311eb0d7d6ee6642e0b25a5562ee622",
        "Created": "2023-11-08T10:33:00.915575032Z",
        "Path": "/docker-entrypoint.sh",
        "Args": [
            "/usr/sbin/mosquitto",
            "-c",
            "/mosquitto/config/mosquitto.conf"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 43304,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2023-11-08T14:50:46.899709677Z",
            "FinishedAt": "2023-11-08T14:50:45.928818789Z"
        },
        "Image": "sha256:67f41ae4ad4b65e532b89ba5c2a2633b8e7cac273d2812599bb16830928bf807",
        "ResolvConfPath": "/var/lib/docker/containers/4d0a9d742a3c5c7fab0a1472ac4e4f239311eb0d7d6ee6642e0b25a5562ee622/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/4d0a9d742a3c5c7fab0a1472ac4e4f239311eb0d7d6ee6642e0b25a5562ee622/hostname",
        "HostsPath": "/var/lib/docker/containers/4d0a9d742a3c5c7fab0a1472ac4e4f239311eb0d7d6ee6642e0b25a5562ee622/hosts",
        "LogPath": "/var/lib/docker/containers/4d0a9d742a3c5c7fab0a1472ac4e4f239311eb0d7d6ee6642e0b25a5562ee622/4d0a9d742a3c5c7fab0a1472ac4e4f239311eb0d7d6ee6642e0b25a5562ee622-json.log",
        "Name": "/mosquitto",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "docker-default",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "/opt/mosquitto/log:/mosquitto/log:rw",
                "/opt/mosquitto:/mosquitto:rw",
                "/opt/mosquitto/data:/mosquitto/data:rw"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "opt_default",
            "PortBindings": {
                "1883/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "1883"
                    }
                ],
                "9001/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "9001"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": [],
            "ConsoleSize": [
                0,
                0
            ],
            "CapAdd": null,
            "CapDrop": null,
            "CgroupnsMode": "private",
            "Dns": null,
            "DnsOptions": null,
            "DnsSearch": null,
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "private",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": null,
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": null,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware",
                "/sys/devices/virtual/powercap"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/23f8b3c79df233b6c789ba2a5e55ef4da69e25cd7244788a8f15af9a7e539b33-init/diff:/var/lib/docker/overlay2/00067e0008101382d5ff5cc36c5174ed5b54aa49392823fbe2569b332ed25887/diff:/var/lib/docker/overlay2/138210ef77ef2a2edd568c0e5fe531d7da3f3ad48504625e64fb465812650199/diff:/var/lib/docker/overlay2/5fbfec7332c49a6f48a39ef444f7f5ef2e16fec8f229d2b3f9a842e27d0c8131/diff",
                "MergedDir": "/var/lib/docker/overlay2/23f8b3c79df233b6c789ba2a5e55ef4da69e25cd7244788a8f15af9a7e539b33/merged",
                "UpperDir": "/var/lib/docker/overlay2/23f8b3c79df233b6c789ba2a5e55ef4da69e25cd7244788a8f15af9a7e539b33/diff",
                "WorkDir": "/var/lib/docker/overlay2/23f8b3c79df233b6c789ba2a5e55ef4da69e25cd7244788a8f15af9a7e539b33/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/opt/mosquitto/log",
                "Destination": "/mosquitto/log",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/opt/mosquitto",
                "Destination": "/mosquitto",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/opt/mosquitto/data",
                "Destination": "/mosquitto/data",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],
        "Config": {
            "Hostname": "4d0a9d742a3c",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "1883/tcp": {},
                "9001/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "VERSION=2.0.18",
                "DOWNLOAD_SHA256=d665fe7d0032881b1371a47f34169ee4edab67903b2cd2b4c083822823f4448a",
                "GPG_KEYS=A0D6EEA1DCAE49A635A3B2F0779B22DFB3E717B7",
                "LWS_VERSION=4.2.1",
                "LWS_SHA256=842da21f73ccba2be59e680de10a8cce7928313048750eb6ad73b6fa50763c51"
            ],
            "Cmd": [
                "/usr/sbin/mosquitto",
                "-c",
                "/mosquitto/config/mosquitto.conf"
            ],
            "Image": "eclipse-mosquitto",
            "Volumes": {
                "/mosquitto": {},
                "/mosquitto/data": {},
                "/mosquitto/log": {}
            },
            "WorkingDir": "",
            "Entrypoint": [
                "/docker-entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {
                "com.docker.compose.config-hash": "d9afb9f136bcc577759b156114a6d688ef12d556a87b5ef6e945d47d09fe2914",
                "com.docker.compose.container-number": "1",
                "com.docker.compose.oneoff": "False",
                "com.docker.compose.project": "opt",
                "com.docker.compose.project.config_files": "docker-compose.yaml",
                "com.docker.compose.project.working_dir": "/opt",
                "com.docker.compose.service": "mosquitto",
                "com.docker.compose.version": "1.29.2",
                "description": "Eclipse Mosquitto MQTT Broker",
                "maintainer": "Roger Light <[email protected]>"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "fcafad0b173c1bea68f9e1e44a45a945188417b2a00b7afbf4dadb1dba09af08",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "1883/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "1883"
                    },
                    {
                        "HostIp": "::",
                        "HostPort": "1883"
                    }
                ],
                "9001/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "9001"
                    },
                    {
                        "HostIp": "::",
                        "HostPort": "9001"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/fcafad0b173c",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "opt_default": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "mosquitto",
                        "4d0a9d742a3c"
                    ],
                    "NetworkID": "04cbd627f22fb1c486027db1b6f6608f0dc22581b97fee3a00306818e95a2f28",
                    "EndpointID": "1c697e684fa02c5534a47e4476567a02048ec388bbf55b43dd5444eba5e1a386",
                    "Gateway": "172.18.0.1",
                    "IPAddress": "172.18.0.3",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:12:00:03",
                    "DriverOpts": null
                }
            }
        }
    }
]

I’ve always struggled with the Mosquitto .config file. Getting a config that yielded a .log file I could find took some head scratching.

So combined with the mosquitto.conf file I showed you, this is how I create my docker container for mosquitto (bash script below), I use a different type docker ‘config’ stuff than you do, but the command show map similar:

The combo of these two, give me a mosquitto log file located in:

/home/user/mosquitto-2/m.log

/home/user/mosquitto-2 is the directory on the host machine where I run the mosquitto docker image from.

FYI, since you appear to have portainer running in your docker system, you should be able to see the info about docker containers there.

So if I do the following command on the host, I see the following output:

cat /home/user/mosquitto-2/m.log | grep zigbee | less

I see a bunch of entries like below, these are zigbee2mqtt and home assistant connecting to the mqtt broker:

2023-11-08T11:34:18: auto-AE8F0380-797A-F526-336D-5BDF2F54E4BA 0 test_zigbee2mqtt/0xa4c13872c7cd3006
2023-11-08T11:34:18: mqttjs_d94bb9f3 0 zigbee2mqtt/#
2023-11-08T11:34:18: mqttjs_839f4685 0 test_zigbee2mqtt/#
2023-11-08T11:34:21: 2gWHVJr2YKZGU4SrYCACn2 0 test_zigbee2mqtt/0x00124b001ccc6801
2023-11-08T11:34:21: 2gWHVJr2YKZGU4SrYCACn2 0 test_zigbee2mqtt/0x00124b001ccc6801/availability
2023-11-08T11:34:21: 2gWHVJr2YKZGU4SrYCACn2 0 test_zigbee2mqtt/0x00124b001cd49b45
#!/usr/bin/env bash
#
# docker-run.sh
# 202311081120
#
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
# Unofficial Bash Strict Mode (Unless You Looove Debugging)
set -euo pipefail

docker run -i -t -d --name="mosquitto-2" \
    -p 1883:1883 -p 9001:9001 \
    -v /home/user/mosquitto-2:/mosquitto/config \
    -v /home/user/mosquitto-2:/mosquitto/data \
    -v /home/user/mosquitto-2:/mosquitto/log \
    -v /etc/localtime:/etc/localtime:ro \
    --user $(id -u):$(id -g) \
    eclipse-mosquitto:2.0.18
1 Like

Got some stuff to read and look in to :slight_smile: thank you for info

Good hunting!

FYI, this is a useful way to have the useful tool MQTT Explorer ‘always at hand’ in a browser link:

mqtt explorer docker image
https://hub.docker.com/r/smeagolworms4/mqtt-explorer
https://github.com/Smeagolworms4/MQTT-Explorer

cd ~
mkdir -p ~/mqtt-explorer/config
cd ~/mqtt-explorer
docker pull smeagolworms4/mqtt-explorer
docker run -p 4000:4000 -v$(pwd)/config:/mqtt-explorer/config smeagolworms4/mqtt-explorer

http://<docker host ip>:4000


1 Like

OK i updates my mosquitto.conf file to this

persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
listener 1883
log_timestamp_format %Y-%m-%dT%H:%M:%S
connection_messages true
log_type subscribe
log_type unsubscribe
log_type websockets
log_type error
log_type warning
log_type notice
log_type information

## Authentication ##
allow_anonymous true

But it still says

Zigbee2MQTT:info  2023-11-10 23:24:03: Logging to console and directory: '/app/data/log/2023-11-10.23-24-03' filename: log.txt

Zigbee2MQTT:info  2023-11-10 23:24:03: Starting Zigbee2MQTT version 1.33.2 (commit #9996c93)

Zigbee2MQTT:info  2023-11-10 23:24:03: Starting zigbee-herdsman (0.21.0)

Zigbee2MQTT:info  2023-11-10 23:24:08: zigbee-herdsman started (resumed)

Zigbee2MQTT:info  2023-11-10 23:24:08: Coordinator firmware version: '{"meta":{"maintrel":"3 ","majorrel":"6","minorrel":"10","product":8,"revision":"6.10.3.0 build 297"},"type":"EZSP v8"}'

Zigbee2MQTT:info  2023-11-10 23:24:08: Currently 0 devices are joined:

Zigbee2MQTT:info  2023-11-10 23:24:08: Zigbee: disabling joining new devices.

Zigbee2MQTT:info  2023-11-10 23:24:09: Connecting to MQTT server at mqtt://localhost

Zigbee2MQTT:error 2023-11-10 23:24:09: MQTT error: connect ECONNREFUSED 127.0.0.1:1883

Zigbee2MQTT:error 2023-11-10 23:24:09: MQTT failed to connect, exiting...

Zigbee2MQTT:info  2023-11-10 23:24:09: Stopping zigbee-herdsman...

Zigbee2MQTT:info  2023-11-10 23:24:09: Stopped zigbee-herdsman

Using '/app/data' as data directory

I dont (yet) :slight_smile: know how to read a .log file in

/opt/mosquitto/log/mosquitto.log

I don’t have the permissions
I changed

allow_anonymous false to allow_anonymous true

Just to make it more simple

But it still says

No log line matching the '' filter

In the mosquitto log in portainer

i’m not sure what’s not working in this post, but i want to share my mosquitto.conf
i must note that i’m using a proxmox container, but this how its been set-up at my server. (config is probably mostly the same anyway) *if i’m correct.

image

and here the default.conf

image

I had the same issue could not connect, what i did was allowing anonymous access, that got me connected, and from there on i fixed the problem with changing my password again.

1 Like

Can it be that my dir for all the containers is

/opt/

would it be better to store them in

/home/nuc

Linux file systems is still at bit of mystery for me

Hi John,

Just a different question first, can you connect with mqtt explorer ?
If u using windows just download it for windows and see if u can connect.
or even on your phone or tablet.

  1. File System Structure:
  • /opt/: This directory is typically used for the installation of software packages added by the local administrator. It’s a common location for storing additional software that is not part of the operating system’s default installation.
  1. Choosing a Directory for Containers:
  • Docker containers usually don’t need to be placed in a user’s home directory unless there are specific permissions or security considerations. /opt/ is a reasonable location for Docker containers, and it’s often used for system-wide installations.
  1. Mosquitto and Zigbee2MQTT:
  • When running services like Mosquitto and Zigbee2MQTT in Docker containers, the important aspect is to ensure that the containers have the necessary permissions to access the directories and ports they require.
  • Check the Docker run commands or Docker Compose configuration for Mosquitto and Zigbee2MQTT. Make sure they are configured to use the correct ports and directories. For example, Mosquitto typically uses port 1883 for MQTT communication.
  1. Connection Refused Error:
  • If Zigbee2MQTT is getting a “Connection Refused” error when trying to connect to Mosquitto, it suggests that Zigbee2MQTT cannot establish a connection to the MQTT broker.
  • Verify that Mosquitto is running and accessible. You can use the following command to check if Mosquitto is listening on the expected port:

Also i found some info for you on an other forum regarding the same problem:

bash

sudo netstat -tuln | grep 1883

If it’s not running, check the Mosquitto logs for any error messages:

bash

docker logs <mosquitto-container-name>
  • Ensure that Zigbee2MQTT is configured with the correct MQTT broker address and port.
  • If Mosquitto is running in a Docker container, make sure that Zigbee2MQTT can reach the container. Check firewall settings if applicable.
  • If you’re still having issues, you might need to provide more details about your Docker Compose or Docker run commands for Mosquitto and Zigbee2MQTT, as well as relevant configurations.

Always consider security best practices, especially when running services that involve communication over the network. Ensure that sensitive services are properly configured, and access is restricted to prevent unauthorized access.

Also be sure everything is correct in your router.

1 Like