# Trying to use MQTT node for first time, won't connect. Just stuck on connecting w/ yellow square icon

**URL:** <https://discourse.nodered.org/t/trying-to-use-mqtt-node-for-first-time-wont-connect-just-stuck-on-connecting-w-yellow-square-icon/53090>\
**Category:** General\
**Created:** [1 November 2021 20:31 UTC](https://discourse.nodered.org/t/trying-to-use-mqtt-node-for-first-time-wont-connect-just-stuck-on-connecting-w-yellow-square-icon/53090 "2021-11-01T20:31:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![YellowSharkMT](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/yellowsharkmt/32/50363_2.png) [@YellowSharkMT](https://discourse.nodered.org/u/YellowSharkMT)\
**Post date:** [1 November 2021 20:31 UTC](https://discourse.nodered.org/t/trying-to-use-mqtt-node-for-first-time-wont-connect-just-stuck-on-connecting-w-yellow-square-icon/53090/1 "2021-11-01T20:31:48Z")

</div>

Hi there, I'm pretty new to NR so this is probably something very obvious/easy.

I'm running an mqtt instance on my local network, but I can't seem to connect to it from NR. This instance definitely works - I can pub/sub to it from the command-line of my main workstation and it's currently supporting a number of Zigbee-based wireless devices through Home Assistant.

This is what I have done:

1. Verified that I can publish and subscribe to the mqtt instance from a separate computer on my network, using the IP, port, and authorization credentials that I established, along with the topic.
2. Dragged the inject (timestamp) and mqtt nodes into the workspace, and connected them together. (Basically attempting to follow this video: [MQTT Publish and Subscribe Using Node Red - YouTube](https://www.youtube.com/watch?v=XDrwgMSQrEY))
3. Double-clicked the mqtt node and attempted to set up the server info.
4. Under the connection tab, I have added the IP address and confirmed that the default port is correct. I have tried both the v3 and v3-legacy protocols.
5. Under the security tab, I have entered the username and password that I am using successfully from the command-line.  
5a. Note: I have also tried connecting anonymously, after configuring mqtt to allow anonymous connections and re-verifying that I could pub/sub from my workstation without supplying credentials.
6. I've hit the deploy button after making any/all of these changes.

Result:

1. First, the mqtt node has a red-square icon + disconnected message right below the node.
2. After ~10s, this changes to "connecting" with a yellow-square icon, and that's how it remains.

Other:

I'm running NR from a docker container, and I have accessed the shell for this container but I do not know any methods to troubleshoot within this environment. There appears to be some commands available like `mqtt_pub` and `mqtt_sub`, but there are no docs about how to use them. In case it's useful info, I'll also add that mqtt is running on the same physical host as NR, in a separate docker container.

Thanks in advance for any ideas/suggestions.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [1 November 2021 20:51 UTC](https://discourse.nodered.org/t/trying-to-use-mqtt-node-for-first-time-wont-connect-just-stuck-on-connecting-w-yellow-square-icon/53090/2 "2021-11-01T20:51:19Z")

</div>

> [@YellowSharkMT](#):
>
> I'm running NR from a docker container,

This may well be a docker problem, perhaps the container is not setup correctly to allow access out to the broker.

> [@YellowSharkMT](#):
>
> There appears to be some commands available like `mqtt_pub` and `mqtt_sub` , but there are no docs about how to use them

Those are part of the Mosquitto package (mosquitto-clients in fact). [mosquitto\_sub man page | Eclipse Mosquitto](https://mosquitto.org/man/mosquitto_sub-1.html)  
You could test that running in a terminal inside and outside the node-red container to prove whether that is the problem.  
Do you need to use node-red in Docker? I advise against it unless you have a good reason to do it.

---

<div class="post-metadata">

**Author:** ![YellowSharkMT](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/yellowsharkmt/32/50363_2.png) [@YellowSharkMT](https://discourse.nodered.org/u/YellowSharkMT)\
**Post date:** [1 November 2021 21:58 UTC](https://discourse.nodered.org/t/trying-to-use-mqtt-node-for-first-time-wont-connect-just-stuck-on-connecting-w-yellow-square-icon/53090/3 "2021-11-01T21:58:53Z")

</div>

Thanks @Colin! You confirmed my suspicions that it might be an issue with container-to-container communications, which turned out to be absolutely spot-on.

My NR container was assigned to docker's bridge network, and that was apparently the problem. I reset/rebuilt it so that it was able to use the host network, and then after re-trying the steps above I was instantly connected to the mqtt instance.

Thanks very much!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [15 November 2021 21:58 UTC](https://discourse.nodered.org/t/trying-to-use-mqtt-node-for-first-time-wont-connect-just-stuck-on-connecting-w-yellow-square-icon/53090/4 "2021-11-15T21:58:54Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
