Cannot get tasmota to connect to mosquitto broker

I installed HASSOS on Windows 10 Hyper-V and it spins up without issues.

New user cannot embeded more than 1 image and 2 links… so I upload all images to Imgur: The magic of the Internet.

I then installed mosquitto broker, this is the config

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

There is another post that has the similiar issue. I followed it to create a HA user instead of adding a new user in mosquitto broker config.

I validated the connection via MQTTX and it works fine.

But I tried the same settings on my tasmota, it cannot connect.

tasmota log:

00:00:00.001 HDW: ESP8285H16
00:00:00.054 CFG: Loaded from flash at F7, Count 150
00:00:00.059 SER: Set to 8E1 4800 bit/s
00:00:00.181 QPC: Count 1
00:00:00.200 NRG: Init driver 2
00:00:00.203 Project tasmota - Tasmota Plug 1 Version 13.3.0(tasmota)-2_7_4_9(2023-12-12T14:29:05)
00:00:00.207 SER: Set to 8E1 4800 bit/s
00:00:00.210 SNS: Hardware Serial
00:00:00.768 WIF: Connecting to AP1 Roy Channel 9 BSSId 34:E8:94:6F:53:55 in mode 11n as tasmota-DE0496-1174...
00:00:02.505 WIF: Connected
00:00:02.805 HTP: Web server active on tasmota-DE0496-1174 with IP address 192.168.1.103
15:21:55.468 MQT: Attempting connection...
15:21:55.482 MQT: Connect failed to mqtt://172.30.166.248:1883, rc -5. Retry in 10 sec
15:21:58.203 QPC: Reset
15:22:06.844 MQT: Attempting connection...
15:22:06.860 MQT: Connect failed to mqtt://172.30.166.248:1883, rc -5. Retry in 20 sec
15:22:27.754 MQT: Attempting connection...
15:22:27.776 MQT: Connect failed to mqtt://172.30.166.248:1883, rc -5. Retry in 30 sec
15:22:58.755 MQT: Attempting connection...
15:22:58.776 MQT: Connect failed to mqtt://172.30.166.248:1883, rc -5. Retry in 40 sec
15:23:39.754 MQT: Attempting connection...
15:23:39.768 MQT: Connect failed to mqtt://172.30.166.248:1883, rc -5. Retry in 50 sec
15:24:30.756 MQT: Attempting connection...
15:24:30.776 MQT: Connect failed to mqtt://172.30.166.248:1883, rc -5. Retry in 60 sec
15:25:31.788 MQT: Attempting connection...
15:25:31.807 MQT: Connect failed to mqtt://172.30.166.248:1883, rc -5. Retry in 70 sec

I don’t really know what is going on… please help.

In your tasmota config lose the mqtt: just use 172.30.166.248

Just gave it a go… but stil the same

16:09:22.600 MQT: Attempting connection...
16:09:22.813 MQT: Connect failed to 172.30.166.248:1883, rc -2. Retry in 10 sec
16:09:25.207 QPC: Reset
16:09:33.773 MQT: Attempting connection...
16:09:33.991 MQT: Connect failed to 172.30.166.248:1883, rc -2. Retry in 20 sec
16:09:54.760 MQT: Attempting connection...
16:09:54.980 MQT: Connect failed to 172.30.166.248:1883, rc -2. Retry in 30 sec

Is mqtt your user name? And is the password correct

Yes. And I tried with MQTTX it can connect to mqtt broker.

User mqtt.

This is mosquitto broker log. I can see MQTTX connections (172.30.160.1), but never see tasmota connections appear in the log…

I am pretty sure my tasmota is connected to the interenet, as I can send a http command to it. (192.168.1.103 is the tasmota IP address)

I am so close but stuck here… :pensive:

You created people, not user. You need to create a user

I am thinking it might be because my HAOS is installed on my Windows 10 PC with Hyper-V and the IP 172.30.166.248 looks like a virtual machine IP. And when I tested with MQTTX on my PC, I can connect to it because my PC can connect to VM IP since they are (HAOS and MQTTX) in the same device (Windows 10), whereas the tasmota does not know the VM IP that is why it cannot connect. So I guess my problem is, How to connect to the VM in my PC from other devices on the same LAN. I hope this is the right direction.

First of all you need to allow MQTT traffic through the firewall. Second, your network adapter in your VM needs to be set to ‘bridge’, so it gets an address in the 192.168.x.x range.
And you still need to create a user and not a person.

It is finally working! Oh yeah!! So happy. Turned out I need to bridge the connection as @francisp mentioned… To be honest as a new user who is very new to VM, the doc is not clear here…

Here is the step to create a bridge network:



Thank you for all the helps.

1 Like