# MQTT input not connecting

**URL:** <https://discourse.nodered.org/t/mqtt-input-not-connecting/1558>\
**Category:** General\
**Created:** [13 July 2018 15:02 UTC](https://discourse.nodered.org/t/mqtt-input-not-connecting/1558 "2018-07-13T15:02:57Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![E.Strobel](https://avatars.discourse-cdn.com/v4/letter/e/ce73a5/32.png) [@E.Strobel](https://discourse.nodered.org/u/E.Strobel)\
**Post date:** [13 July 2018 15:02 UTC](https://discourse.nodered.org/t/mqtt-input-not-connecting/1558/1 "2018-07-13T15:02:58Z")

</div>

I have been having an issue getting the MQTT input block to connect to my emonPi (raspberry pi system by openenergymonitor). When I connect to the emonPi via SSH through putty, I am able to view all of the MQTT messages. This to me means that everything is working fine on that end, but I could be wrong. When I try to connect the pi to nodered using the mqtt input, I have not been able to connect. My first thought is is there password authentication required before accessing the info passed by MQTT? Thank you for your help.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/9364c14002c0a959250b14639c00bc050929a8a8.png)

---

<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:** [13 July 2018 15:17 UTC](https://discourse.nodered.org/t/mqtt-input-not-connecting/1558/2 "2018-07-13T15:17:21Z")

</div>

> [@E.Strobel](#):
>
> When I connect to the emonPi via SSH through putty, I am able to view all of the MQTT messages.

1. how are you verifing the MQTT messages?
2. is node-red running on the same pi as mqtt is running? If not, you need to provide the ip address in place of 'localhost'

---

<div class="post-metadata">

**Author:** ![E.Strobel](https://avatars.discourse-cdn.com/v4/letter/e/ce73a5/32.png) [@E.Strobel](https://discourse.nodered.org/u/E.Strobel)\
**Post date:** [13 July 2018 15:18 UTC](https://discourse.nodered.org/t/mqtt-input-not-connecting/1558/3 "2018-07-13T15:18:50Z")

</div>

node-red is running on the same pi as mqtt is running

---

<div class="post-metadata">

**Author:** ![ncherry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ncherry/32/27_2.png) [@ncherry](https://discourse.nodered.org/u/ncherry)\
**Post date:** [13 July 2018 15:27 UTC](https://discourse.nodered.org/t/mqtt-input-not-connecting/1558/4 "2018-07-13T15:27:01Z")

</div>

If I understand you correctly, when you run the command from the command line (something like mosquitto\_sub -t ...) it returns the data being sent (old data won't be there unless it was sent with retain).

Can you run, on the pi, the following command?:

netstat -nat | grep LISTEN | grep 1883

That should come back with the address the MQTT server is listening on. 0.0.0.0:1883 means it's listening on all addresses and port 1883 and I'd expect 127.0.0.1 to work properly.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [13 July 2018 15:27 UTC](https://discourse.nodered.org/t/mqtt-input-not-connecting/1558/5 "2018-07-13T15:27:39Z")

</div>

Might be worth playing around with the address - try 127.0.0.1 and/or the actual IP address of the Pi

---

<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:** [13 July 2018 15:39 UTC](https://discourse.nodered.org/t/mqtt-input-not-connecting/1558/6 "2018-07-13T15:39:15Z")

</div>

> [@E.Strobel](#):
>
> node-red is running on the same pi as mqtt is running

You didn't answer @zenofmud's first question.  
Are you running mosquitto\_sub on the pi to verify the MQTT messages are getting through?

---

<div class="post-metadata">

**Author:** ![E.Strobel](https://avatars.discourse-cdn.com/v4/letter/e/ce73a5/32.png) [@E.Strobel](https://discourse.nodered.org/u/E.Strobel)\
**Post date:** [13 July 2018 15:40 UTC](https://discourse.nodered.org/t/mqtt-input-not-connecting/1558/7 "2018-07-13T15:40:06Z")

</div>

> [@ncherry](#):
>
> If I understand you correctly, when you run the command from the command line (something like mosquitto\_sub -t ...) it returns the data being sent (old data won't be there unless it was sent with retain).

exactly

> [@ncherry](#):
>
> netstat -nat | grep LISTEN | grep 1883

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/053def345e874e885f21796a1056ac8902b222ae.png)

---

<div class="post-metadata">

**Author:** ![E.Strobel](https://avatars.discourse-cdn.com/v4/letter/e/ce73a5/32.png) [@E.Strobel](https://discourse.nodered.org/u/E.Strobel)\
**Post date:** [13 July 2018 15:45 UTC](https://discourse.nodered.org/t/mqtt-input-not-connecting/1558/8 "2018-07-13T15:45:54Z")

</div>

Sorry I forgot to answer that question. I am running

```auto
$ mosquitto_sub -v -u 'emonpi' -P 'password' -t 'emon/emonpi/power1'

```

and getting back:

```auto
emon/emonpi/power1 4550
emon/emonpi/power1 4516
emon/emonpi/power1 4558
emon/emonpi/power1 4553

```

---

<div class="post-metadata">

**Author:** ![E.Strobel](https://avatars.discourse-cdn.com/v4/letter/e/ce73a5/32.png) [@E.Strobel](https://discourse.nodered.org/u/E.Strobel)\
**Post date:** [13 July 2018 15:56 UTC](https://discourse.nodered.org/t/mqtt-input-not-connecting/1558/9 "2018-07-13T15:56:47Z")

</div>

> [@cymplecy](#):
>
> try 127.0.0.1 and/or the actual IP address of the Pi

in place of localhost?

---

<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:** [13 July 2018 15:56 UTC](https://discourse.nodered.org/t/mqtt-input-not-connecting/1558/10 "2018-07-13T15:56:49Z")

</div>

Click on the pen next to the broker address in the mqtt node and you can setup the credentials there.

---

<div class="post-metadata">

**Author:** ![E.Strobel](https://avatars.discourse-cdn.com/v4/letter/e/ce73a5/32.png) [@E.Strobel](https://discourse.nodered.org/u/E.Strobel)\
**Post date:** [13 July 2018 16:08 UTC](https://discourse.nodered.org/t/mqtt-input-not-connecting/1558/11 "2018-07-13T16:08:56Z")

</div>

If it is giving the message, "Deploy Failed. Not Authorized" that must mean mqtt doesn't like my username or password, right?

---

<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:** [13 July 2018 16:18 UTC](https://discourse.nodered.org/t/mqtt-input-not-connecting/1558/12 "2018-07-13T16:18:05Z")

</div>

If you mean the MQTT user/pwd setup in the MQTT config node then no, I don't think so, that would just fail to connect to MQTT, the error is saying you cannot deploy the flow itself. I am not sure how that would happen. Have you got user/pwd configured for node red itself? If not then I suggest doing a full refresh of the browser and check you can deploy a minor change, if that is ok then try the MQTT config again.

---

<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:** [13 July 2018 16:40 UTC](https://discourse.nodered.org/t/mqtt-input-not-connecting/1558/13 "2018-07-13T16:40:53Z")

</div>

What version of node-red?

---

<div class="post-metadata">

**Author:** ![E.Strobel](https://avatars.discourse-cdn.com/v4/letter/e/ce73a5/32.png) [@E.Strobel](https://discourse.nodered.org/u/E.Strobel)\
**Post date:** [13 July 2018 17:12 UTC](https://discourse.nodered.org/t/mqtt-input-not-connecting/1558/14 "2018-07-13T17:12:36Z")

</div>

> [@zenofmud](#):
>
> What version of node-red?

I am using version v0.15.3.

---

<div class="post-metadata">

**Author:** ![E.Strobel](https://avatars.discourse-cdn.com/v4/letter/e/ce73a5/32.png) [@E.Strobel](https://discourse.nodered.org/u/E.Strobel)\
**Post date:** [13 July 2018 17:17 UTC](https://discourse.nodered.org/t/mqtt-input-not-connecting/1558/15 "2018-07-13T17:17:15Z")

</div>

When I refreshed it asked me for Node-RED credentials again, and then when I went to test mqtt input it was connected. I'm not really sure what happened but thank you for the help.

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [13 July 2018 19:06 UTC](https://discourse.nodered.org/t/mqtt-input-not-connecting/1558/16 "2018-07-13T19:06:04Z")

</div>

E. - that is a very old version of node-red. If you are able to run the upgrade scripts, there are many enhancements that you may enjoy. Just be sure to make a copy of your sdcard first ;\*)

---

<div class="post-metadata">

**Author:** ![E.Strobel](https://avatars.discourse-cdn.com/v4/letter/e/ce73a5/32.png) [@E.Strobel](https://discourse.nodered.org/u/E.Strobel)\
**Post date:** [13 July 2018 19:07 UTC](https://discourse.nodered.org/t/mqtt-input-not-connecting/1558/17 "2018-07-13T19:07:42Z")

</div>

I will do that, thank you

---

<div class="post-metadata">

**Author:** ![ncherry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ncherry/32/27_2.png) [@ncherry](https://discourse.nodered.org/u/ncherry)\
**Post date:** [13 July 2018 19:40 UTC](https://discourse.nodered.org/t/mqtt-input-not-connecting/1558/18 "2018-07-13T19:40:57Z")

</div>

did you set up the Node-Red MQTT entry with the user and password info under the security section of the node?

---

<div class="post-metadata">

**Author:** ![E.Strobel](https://avatars.discourse-cdn.com/v4/letter/e/ce73a5/32.png) [@E.Strobel](https://discourse.nodered.org/u/E.Strobel)\
**Post date:** [13 July 2018 19:59 UTC](https://discourse.nodered.org/t/mqtt-input-not-connecting/1558/19 "2018-07-13T19:59:10Z")

</div>

I did after @Colin mentioned doing so, issue resolved now.
