MQTT integration with Tailscale

Does anyone have the MQTT integration working over a Tailscale connection?

I have two HA instances at different locations. One is running an MQTT broker with the official add on. I can successfully connect the second to it via Zerotier, but Tailscale fails using any of the Tailscale iP, the local IP and the Tailscale assigned domain.

Any ideas?

Do you both HA nodes tailscales set to enable subnet routing, you also need to make sure you point at your homeassistant ip address:1883 unless you are using websockets or TLS of course.

Another problem will arise if your two HA instances are on the same IP range… meaning HA one is something like 192.168.1.x and HA two is also 192.168.1.x… they need to be different ip ranges. Even if they are on difference ranges you need to add static routes via the tailscale network so that they can see each other

Thanks very much for responding. The instances aren’t on the same IP range, and I’m using the correct port.

I’ll double-check that subnet routing is enabled on both, but this was also not working with 100.x.x.x Tailscale IPs.

Do you have it working?

Lemme see if I get anywhere with subnet routing.

Appreciate it.

I forgot to say that you need to change the routing on the tailscale website not in HA.
Site: Tailscale Console

Here is a picture of where you have to set the subnet routing:


Note that I use Exit node enable as I can then use HA as a VPN for my Cell Phones

@ronschaeffer Did you ever get this working? I think I am trying to do the same thing. I am trying to get the MQTT broker on a home assistant instance to be a bridge back to another Mosquitto MQTT broker on a different server. Tailscale is working properly. I can access the home assistant web UI via the tailscale IP and all my other Tailscale nodes work, but I can’t get the MQTT bridge to connect back to my other server using the 100.x.x.x Tailscale IP.
I’m thinking it is because the add-ons are running in docker containers on HA.

No. I haven’t taken the time to mess around with it since. I will at some point but in the meantime, I’ve just left it on Zerotier. That’s very easy to set up if you want a quick solution, even if it feels nonsensical to be running it alongside Tailscale.

Ok, I’ll look into that. Or I may set up a standalone MQTT broker. If I had Mosquitto on a separate host that had its own native Tailscale client, it should work fine.

@ronschaeffer I got it working using Tailscale from this repo: GitHub - tsujamin/hass-addons

Thanks, I’ll give that a try. Do you have any idea what the difference is?

No, I didn’t look at the differences on how they are implemented. The second one has more configuration options, but the main difference is however it is exposing that tailscale network interface to the other add-ons.

@bobthenut What exact settings did you use? After installing the addon with the default settings, I cannot send messages via MQTT.

I’ve also been looking into this to figure out how to connect two MQTT servers from different locations via Tailscale. Since all options with separate add-ons (for MQTT and Tailscale) led to different problems, I decided to create an add-on that contains both Tailscale and MQTT. With this add-on the MQTT bridge mode can be activated.
Works fine so far, feel free to give it a try: addon-mosquitto-tailscale/DOCS.md at 5d33edbb0876c38b4256ce2fae475086ddb5681d · elcajon-tech/addon-mosquitto-tailscale · GitHub

1 Like

@elcajon Does this mean that I can have a regular-local MQTT server and your Tailscale-enabled-remote MQTT server up and running at the same time?

Not quite, the add-on replaces the official one. With it you have both the functionality of the normal add-on and additionally the possibility to access the mosquitto server remotely via Tailscale.
I have not tried if both add-ons work in parallel. I assume, there will be problems with the official Home Assistant Core integration, as it only allows one instance.

I originally came here to ask a question but figured I’d followup with an update.

I’ve set up Home Assistant Core on a free tier VM in Google Cloud that’s within my Tailscale network, solely to access a Luxpower EG4 solar inverter that can communicate over MQTT.

I recently purchased a Monitor My Solar Dongle to interface with my inverter and am planning to use their Monitor My Solar Home Assistant integration that’s on HACS.

I set up Eclipse Mosquitto broker on the GCP server and for now opened up just ports 1883. Unfortunately, the 3rd party dongle doesn’t support encrypted traffic. My initial plan is for the dongle to talk directly to the server via the open MQTT port. Once I have things working I intend to consider relaying the data through a MQTT broker running on my home network so that I can attempt to keep my data within my Tailscale network.

I found this post pretty useful for quickly enabling me to set up and configure HA Core and Mosquitto. For now I am assuming it will be possible to route MQTT over Tailscale, I just need to set up a broker to relay.