# Nodemcu cannot connect to mqtt

**URL:** <https://discourse.nodered.org/t/nodemcu-cannot-connect-to-mqtt/38384>\
**Category:** General\
**Created:** [2 January 2021 08:43 UTC](https://discourse.nodered.org/t/nodemcu-cannot-connect-to-mqtt/38384 "2021-01-02T08:43:31Z")\
**Posts on this page:** 12\
**Page:** 4

<div class="post-metadata">

**Author:** ![sam\_r](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@sam\_r](https://discourse.nodered.org/u/sam_r)\
**Post date:** [8 January 2021 07:31 UTC](https://discourse.nodered.org/t/nodemcu-cannot-connect-to-mqtt/38384/64 "2021-01-08T07:31:53Z")

</div>

wow .. thanks .. now nodemcu and the broker is on same network and works perfectly

---

<div class="post-metadata">

**Author:** ![sam\_r](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@sam\_r](https://discourse.nodered.org/u/sam_r)\
**Post date:** [8 January 2021 07:34 UTC](https://discourse.nodered.org/t/nodemcu-cannot-connect-to-mqtt/38384/65 "2021-01-08T07:34:11Z")

</div>

thanks got it

---

<div class="post-metadata">

**Author:** ![sam\_r](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@sam\_r](https://discourse.nodered.org/u/sam_r)\
**Post date:** [8 January 2021 07:35 UTC](https://discourse.nodered.org/t/nodemcu-cannot-connect-to-mqtt/38384/66 "2021-01-08T07:35:15Z")

</div>

thanks now nodemcu connected to mqtt broker after i connect them to same network

---

<div class="post-metadata">

**Author:** ![sam\_r](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@sam\_r](https://discourse.nodered.org/u/sam_r)\
**Post date:** [8 January 2021 07:36 UTC](https://discourse.nodered.org/t/nodemcu-cannot-connect-to-mqtt/38384/67 "2021-01-08T07:36:34Z")

</div>

but connection not stable ,, getting into reconnect mode and get connect , work for sometime then again disconnect and try to reconnect .. any solution for that

---

<div class="post-metadata">

**Author:** ![sam\_r](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@sam\_r](https://discourse.nodered.org/u/sam_r)\
**Post date:** [8 January 2021 07:38 UTC](https://discourse.nodered.org/t/nodemcu-cannot-connect-to-mqtt/38384/68 "2021-01-08T07:38:31Z")

</div>

Thankyou everyone for expert advice .. I finally able to connect iot to nodered through mqtt broker. I appreciate everyone's help and advice .. This makes my more interest in node-red.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [8 January 2021 07:39 UTC](https://discourse.nodered.org/t/nodemcu-cannot-connect-to-mqtt/38384/69 "2021-01-08T07:39:54Z")

</div>

Sounds like that could be a WiFi strength issue.  
Could you try moving the NodeMCU nearer to the acess point and see if the reconnections reduce/stop??

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [8 January 2021 07:43 UTC](https://discourse.nodered.org/t/nodemcu-cannot-connect-to-mqtt/38384/70 "2021-01-08T07:43:50Z")

</div>

The suggestion from @krambriw about using a broker on the Cloud is a good one.  
I use BeeBotte for my remote weather stations and have two MQTT-In nodes in Node-RED.  
One is listening for traffic from my home network and the other for remote traffic from the Cloud.  
 ![Screen Shot 01-08-21 at 07.56 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/1/f111503e376a2dba4a45207675ef54508a32bf0e.jpeg)

---

<div class="post-metadata">

**Author:** ![sam\_r](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@sam\_r](https://discourse.nodered.org/u/sam_r)\
**Post date:** [8 January 2021 07:46 UTC](https://discourse.nodered.org/t/nodemcu-cannot-connect-to-mqtt/38384/71 "2021-01-08T07:46:12Z")

</div>

I just make server for testing .. for future sure going to use some stable and powerful one

---

<div class="post-metadata">

**Author:** ![sam\_r](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@sam\_r](https://discourse.nodered.org/u/sam_r)\
**Post date:** [8 January 2021 08:09 UTC](https://discourse.nodered.org/t/nodemcu-cannot-connect-to-mqtt/38384/72 "2021-01-08T08:09:35Z")

</div>

I am new to node-red but definately going to go for more in it .. I am going to disturb you alot in future .. haha

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [8 January 2021 09:52 UTC](https://discourse.nodered.org/t/nodemcu-cannot-connect-to-mqtt/38384/73 "2021-01-08T09:52:28Z")

</div>

> [@sam\_r](#):
>
> but connection not stable ,, getting into reconnect mode and get connect , work for sometime then again disconnect and try to reconnect .. any solution for that

Where are you seeing this? In NR or in the nodemcu? (details are important)

This is most likely due to the 'keep alive' interval. If you haven't read it yet. I suggest you read [hivehq.com](http://hivehq.com)' [Tags](https://www.hivemq.com/tags/mqtt-essentials) and the part  
[What Is MQTT Keep Alive and Client Take-Over? – MQTT Essentials Part 10](https://www.hivemq.com/blog/mqtt-essentials-part-10-alive-client-take-over/)

---

<div class="post-metadata">

**Author:** ![sam\_r](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@sam\_r](https://discourse.nodered.org/u/sam_r)\
**Post date:** [9 January 2021 01:11 UTC](https://discourse.nodered.org/t/nodemcu-cannot-connect-to-mqtt/38384/74 "2021-01-09T01:11:47Z")

</div>

That's the issue from nodemcu side ..thanks for the link.

---

<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:** [30 January 2021 03:57 UTC](https://discourse.nodered.org/t/nodemcu-cannot-connect-to-mqtt/38384/75 "2021-01-30T03:57:54Z")

</div>

Closed on 30 January 2021 03:57 UTC

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

[Previous page](https://discourse.nodered.org/t/nodemcu-cannot-connect-to-mqtt/38384.md?page=3)
