#Zigbee2mqtt - mqtt broker connection issue

1 messages ยท Page 1 of 1 (latest)

willow talon
#

Hello, ran some updates, now my z2m won't connect to the mqtt broker z2m: MQTT failed to connect, exiting... (connect ECONNREFUSED 172.17.0.4:1883), I changed no settings/configs
mqtt:
base_topic: zigbee2mqtt
server: mqtt://172.17.0.4

#

Container setup, zigbee2mqtt was using 172.17.0.4, that address appears briefly and disappears soon after container startup, logs show as above although I have both a username and password and config set to allow anyone to connect, was working well until updating.

errant juniper
#

Depending on how the containers are set up you can use the ip of the system or the name of the container. Using docker internal ips is a bad idea.
Please share the network settings for the Z2M container.

willow talon
#

from the config file you mean?

errant juniper
#

I don't know how you created the Mosquitto container. If you created in in portainer I need to see its settings there.
I much prefer a compose file.

#

I basically want to check if you "forwarded" the port. If yes you can use the ip of the system. It doesn't seem to be sharing a stack/network with HA so you cannot just refer to it by name.

willow talon
#

z2m just says bridge in portainer, mosquitto has other fields as follows - bridge 172.17.0.2 172.17.0.1 02:42:ac:11:00:04

errant juniper
#

I need a picture here.

willow talon
#

ok, bear with me..

#

error msg seems to be permission related, but I have made no changes

errant juniper
#

The important part is the Port configuration section.

willow talon
#

port is 1883

errant juniper
#

I need to see it in full.

willow talon
#

root@CM3588-Plus:/opt/mosquitto/config# cat mosquitto.conf
persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
listener 1883

#

from mosquitto.conf

errant juniper
#

I meant the Port configuration section from the portainer GUI. Just scroll up in your picture.

willow talon
#

I don't see mention of the port at all

errant juniper
#

Then click Duplicate/Edit and check Port mapping.

willow talon
errant juniper
willow talon
#

that shot from mosquitto container

errant juniper
#

Alright, you should be able to use 191.168.2.15 as ip for the broker since the 1883 port is published.

willow talon
#

ok, and the mosquitto container too?

errant juniper
#

Not sure what you mean.

#
mqtt:
  base_topic: zigbee2mqtt
  server: mqtt://191.168.2.15

Try this for Z2M.

willow talon
#

all this was working on the bridge network 'till now *172XXXXX"

errant juniper
#

You can check the container's ip via docker inspect too but it's not a good idea to use those ips as they can change.
I'm not sure why portainer shows no ip in the GUI for that container. Check the container's log to see if it's even running properly.

willow talon
#

the bridge ip shows briefly and is removed when the connection is rejected by the mosquitto container

#

portainer and mosquitto containers both show 172 addresses

#

the z2m container logs show just the error I posted, otherwise it was running well with just mqtt messages and no errors

errant juniper
#

You need to check the mosquitto container logs as that's the one not showing an ip.

willow talon
#

mosquitto container has never shown any log messages

errant juniper
#

Hmm. Well, see if you can connect with the ip I gave you above. Also see if you can connect via MQTT Explorer to that ip.

willow talon
#

mosquitto container shows 172 ip address, it's z2m that doesn't

errant juniper
#

Ah, right.

willow talon
#

I don't really know enough about it, just followed some guides, but prior to updating it was working well, z2m was showing 172.17.10.4 and does on restart, until the connection gets rejected by mosquitto, then the ip is removed from the portainer display

willow talon
#

sorry, was afk, I'll see..

errant juniper
#

You can use this to get a list of your containers' internal ips

docker ps -q | xargs docker inspect --format '{{ .Name }} {{range .NetworkSettings.Networks}} {{.IPAddress}}{{end}}' | tr -d '/' | column -t

Not really useful if you ask me.

willow talon
#

now it's back..

#

docker ps -q | xargs docker inspect --format '{{ .Name }} {{range .NetworkSettings.Networks}} {{.IPAddress}}{{end}}' | tr -d '/' | column -t
homeassistant
configurator
mosquitto 172.17.0.2
zigbee2mqtt
portainer 172.17.0.3

errant juniper
#

I'd need to see the network/port output of docker inspect zigbee2mqtt.

visual palmBOT
#

Please use a code share site to share code or logs, for example:

Please don't use Pastebin, since it can randomly add spaces to the main view. Please also don't share text as images since it makes it harder for people to help you. Remember that others may have colour blindness, impaired vision, etc.

errant juniper
#

But before we do anything else, please test what I shared above. See if you can connect to the broker.

#

Some of my containers have no internal ip either but they work fine. Host networking can cause that, for example. Or in other words, don't focus on that ip for now. We are getting nowhere like that.

willow talon
#

Ok, I entered the local ip address in the z2m config, restarted the z2m container, now I can see the z2m GUI and controll devices from there, home assistant is not connected and portainer still shows the 172 bridge address

#

I was previously unable to view the z2m gui

errant juniper
#

Alright so issue fixed. Can you share docker inspect zigbee2mqtt?

#

If you put both containers into the same network you can refer to them by the name. System ip works too, but unless you reserved it it can change too.
There's many ways to do things. You could use the hostname of your system for example but whether that works depends on your networking setup.

willow talon
#

didn't see a yaml option, hopefully that's what you wanted, still seems to show that bridge ip

errant juniper
#

Yeah that's fine. Hmm. That looks fairly normal.

#

My guess is the ip went missing because the Z2M app inside basically dies if it cannot connect to the broker.

willow talon
#

yeah, that sounds about right, I can now manually switch devices from port 8080 z2m, but HA is disconnected so automations don't work and no sensor data on dash

errant juniper
#

Reconfigure the MQTT integration and give it the same ip.

willow talon
#

I picked a difficult road for a noob I guess, was stoked when I got it working and has been fine 'till now

errant juniper
#

In the case of HA you can actually use localhost since it uses host networking. At least if you followed the docs.

#

Well portainer might look easier but it's not. It's extremely annoying and difficult to help and get help with it.

#

If you have to use portainer use its stack feature. You can use compose formatting in there.

willow talon
#

I still see the bridge 172 address in that output though too

errant juniper
#

Probably because the container now isn't dead ๐Ÿ™‚
I only care that it works. What portainer shows isn't really of interest to me.

willow talon
#

mosquitto config just lists listener on 1883, where would I change to the local network?

errant juniper
#

I did not say mosquitto, I said MQTT integration.

willow talon
#

ok, logs in z2m are normal now, just mqtt chatter

errant juniper
willow talon
#

thanks, restarting HA

errant juniper
#

I assume 191.168.2.15 is reserved in your router with a static DHCP lease?

willow talon
#

it's not yet ๐Ÿ™‚ on my todo list, but that seems to have done the trick, HA sees my devices now, thank you

#

I did see recommendations for a static ip, had no issue with that as yet

#

I wonder why the update broke things?

errant juniper
#

Unless your server goes down for a while you will probably keep the ip but it can technically change at any time.

#

I don't know how docker chooses to assign the internal ips. Maybe recreation caused it to get a new one.

willow talon
#

well, portainer was showing the same 172 addresses I had from the beginning and it still does, it's confusing

#

I'm learning things all the time but very early days atm ๐Ÿ™‚

errant juniper
#

No idea then.

willow talon
#

anyway, thanks for the assistance ๐Ÿ™‚

#

I can just re-create the containers to pull a late image, but not the portainer container, I guess it would have to be created from a docker-compose file?

errant juniper
#

Many ways. I think it's best to update it via the OMV GUI.

willow talon
#

OMV is up to date, not sure I can do it from there

errant juniper
#

Pretty sure you can in the specific section for it.

willow talon
#

Portainer is containerized too though

errant juniper
#

Sure but the portainer container was created by the OMV GUI, no?

willow talon
#

docker command?..not sure now, I'll check the guide article