How to connect to MQTT server from inside a private network?

I am new to this forum but I have been playing with HA for quite some months by now. For the bigger part I managed to configure 90% of my home already in HA, but this is the first time that I reached the point that asking is smarter/faster then trying to solve it by myself (although i hope so :slight_smile: )

My current HA setup looks in short like this:

  • Windows ThinClient pc with virtualbox on it running a HA Supervisor 2023.2.3
  • Many things integrated (roomba, eufy, visonic alarm, …)
  • The majority of devices running on zigbee and connected via zigbee2MQTT because of the bigger number of devices supported

What I am currently trying to do is to connect and energy meter on the P1 port of my electricity/gas meter. So far so good, but the point that I am struggling with is that I am not able to make a successfull (network) connection between my energy meter and my MQTT server running on local (so it seems)

  • if I look in my Zigbee2MQTT configuration then it is pointing to mqtt://core-mosquitto:1833
  • a nslookup of this adres results in 172.30.33.0, this is totally different from the internal network ip adress of my HA instance, but I can’t explain this because I am very bad with network related things.
  • I configured my virtualbox VM image with a Bridge Network adapter and the ip address that it gets assigned when starting up HA is something like 192.168.50.171
  • I tried connecting my smart energy meter to mqtt://192.168.50.171:1833, but the connection is failing.
  • because my virtualbox is running on Windows, I also tried disabling the Windows Firewall but that didn’t make any difference.

Not sure what I do wrong and/or should do different… I guess I am a little bit stuck on the networking part toward a HA instance.

  • Where is the 172.30.33.0 address coming from, is it something internal HA networking?
  • To which ip address / port should I point my smart energy meter so it’s able to connect?
  • Should I open somewhere a port in a ‘firewall’?
  • I tried configuring the virtualbox with NAT and port forwarding, but then my HA instance isn’t even accesible anymore.
  • Does my Mosquitto broker (mqtt://core-mosquitto) really runs locally?

Hopefully there are some network / mqtt experts on this forum that can help or push me in the right direction…

It is the internal docker IP

192.168.50.171:1833
You can try MQTT_Explorer to test :wink:

ps: @michaelblight has a point here, port is normally 1883, not 1833 :wink:

Great tips @aceindy … didn’t knew about the MQTT_Explorer :slight_smile:

Let me check what this tool learns, but in the end… if it is a networking/routing/firewall issue then I am afraid that I am still stuck because I don’t know enough about HAOS networking/firewall configuration.

It should be available in your network using HA’s IP address…at least it is at my place :wink:

Perhaps you need a username/password ?
See mqtt broker config:

logins:
  - username: mymqttuser
    password: mymqttpassword

The MQTT port is normally 1883, not 1833. Is that a typo or a mistake?

Once you have IP routed through from the LAN to HASS, there’s not much to configure. HASSOS does have some additional complexity in the way it maps device names to ensure they persist between reboots (basically, where there is a choice, use the longer device path!), but for IPv4, it looks like you’ve done the heavy lifting (Note: I use a Yellow on HASSOS so have less VB VM knowledge).

The trick with most network issues is to test your understanding - e.g. MQTT Explorer is a great example of a tool that gives you a ‘device level’ view of what HASS is doing from network through to application layer. Most MQTT issues are simple to spot, like a bad set of credentials, a bad hostname/ IP, or IPv6 being dropped by the hypervisor. Telnet to the IP and port is sometimes all you need to check.

The Mosquotto command line on a RPi is also useful (never looked to see if there is a Win port), e.g.:

# sub to ALL topics = #
mosquitto_sub -d -i "monitor" -h 192.168.99.99 --username 'USER' --pw 'PASS' -v -t '#'

# With fancy colouring on a Linux console
mosquitto_sub -d -i "monitor" -F '\e[92m%t \e[96m%p\e[0m' -h 192.168.99.99 --username 'USER' --pw 'PASS' -v -t '#'

Out of completeness, can I suggest a walk-though of all MQTT settings as a check?:

If this helps, :heart: this post!