Open joekerna opened 4 years ago
I believe that if you use localhost as the MQTT_HOST, it resolves to the IP of the container itself, which there is no MQTT server there. I assume you are attempting to connect to Mosquitto running on the same machine in some other fashion.
How is your Mosquitto server setup? Is it running as a container on the same physical machine? And how is the working client setup (as a container, or a different method?)
Mosquitto is running locally on the same machine (no docker). rtl2hass is setup using docker-compose
Will it help, if I change my docker-compose.yaml to
MQTT_HOST=127.0.0.1
I don't think so. If you do some reading regarding Docker, depending on your OS (Windows/Mac/Linux), there may be some DNS entries you can use to reference the actual localhost from within the container.
Otherwise, adding --net=host to your docker-compose file should work, although it's far less secure.
How do you do it? Is there a recommended way?
I run Mosquitto as a Home Assistant add-on (essentially a Docker container), and have a DNS record for mqtt.mylocaldomain.com, which points to my Home Assistant server. So anything needing to connect to MQTT uses that DNS name.
Really this comes down to a DNS issue. Are you running any sort of DNS server in your environment?
Another thing you could try is using the IP of the machine you have Mosquitto installed on, rather than a hostname.
I've created the following docker-compose.yml
I've triple checked the username, password and port. Mosquitto is running on localhost and receiving MQTT messages from another client successfully.
However I get the following error:
Is it possible to get more debug information as to why the connection is refused?