# How to run mosquitto in parallel to node-red outside "local" mode?

**URL:** https://discourse.nodered.org/t/how-to-run-mosquitto-in-parallel-to-node-red-outside-local-mode/69423
**Category:** General
**Created:** [22 October 2022 14:10 UTC](https://discourse.nodered.org/t/how-to-run-mosquitto-in-parallel-to-node-red-outside-local-mode/69423 "2022-10-22T14:10:38Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Gawan](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@Gawan](https://discourse.nodered.org/u/Gawan)
#### Post date: [22 October 2022 14:10 UTC](https://discourse.nodered.org/t/how-to-run-mosquitto-in-parallel-to-node-red-outside-local-mode/69423/1 "2022-10-22T14:10:38Z")

</div>

Hi,  
I am running Node-Red successfully on a raspberry pi and now I want to run mosquitto the same way on this pi to have a MQTT Broker.  
I tried several explanations (they are all more or less the same), but when I start the broker I get this error message:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/f/9f1a8d2ba0faf73713e4335f8fdf069a25095c0e.png)

and the only device that is allowed to connect to the broker is the raspberry itself.  
I edited the conf-file as described here, but with no success:

> **[Install Mosquitto Broker Raspberry Pi | Random Nerd Tutorials](https://randomnerdtutorials.com/how-to-install-mosquitto-broker-on-raspberry-pi/)**
>
> This tutorial shows how to install the Mosquitto Broker for MQTT communication on a Raspberry Pi board.

What am I doing wrong ?  
BR

---

<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: [22 October 2022 14:22 UTC](https://discourse.nodered.org/t/how-to-run-mosquitto-in-parallel-to-node-red-outside-local-mode/69423/2 "2022-10-22T14:22:36Z")

</div>

Normally after installing mosquitto on a Pi, it gets installed as a system service so no need to manually start it

Can you just check if this is case by re-booting the Pi and then doing

` ps -aux | grep mosquitto`  
and see if you get similar to this which shows it running

```auto
pi@pi128gb:~/.nrmqtt $ ps -aux | grep mosquitto
mosquit+ 489 0.0 0.3 12232 3540 ? Ss Oct19 3:48 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
pi 12186 1.0 0.0 7452 568 pts/2 S+ 15:19 0:00 grep --color=auto mosquitto
pi@pi128gb:~/.nrmqtt $

```

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [22 October 2022 14:32 UTC](https://discourse.nodered.org/t/how-to-run-mosquitto-in-parallel-to-node-red-outside-local-mode/69423/3 "2022-10-22T14:32:07Z")

</div>

Did you configure mosquitto for anonymous access or require a user name and password?

What changes have you made to /etc/mosquitto/mosquitto.conf?

Have you restarted mosquitto?

---

<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: [22 October 2022 14:39 UTC](https://discourse.nodered.org/t/how-to-run-mosquitto-in-parallel-to-node-red-outside-local-mode/69423/4 "2022-10-22T14:39:57Z")

</div>

> [@Gawan](#):
>
> What am I doing wrong

The tutorial is misleading in this area. When you run `mosquitto -v` I think it does not use the config file you editted. Instead you should run it as a service by running  
`sudo systemctl start mosquitto`  
Then run  
`systemctl status mosquitto`  
to check it is running ok.  
Also I suggest including this in the config file, otherwise the timestamps in the log are not readable.

```auto
# human readable timestamps in log
log_timestamp true
log_timestamp_format %Y-%m-%d %H:%M:%S

```

Then if you look in the mosquitto log using  
`sudo cat /var/log/mosquitto/mosquitto.log`  
you should see everything that is going on.

---

<div class="post-metadata">

### Author: ![Gawan](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@Gawan](https://discourse.nodered.org/u/Gawan)
#### Post date: [22 October 2022 15:30 UTC](https://discourse.nodered.org/t/how-to-run-mosquitto-in-parallel-to-node-red-outside-local-mode/69423/5 "2022-10-22T15:30:54Z")

</div>

Ah ok, I see  
I was always starting the service with

> mosquitto -v

to do the R&D activities in node-red, but never did the final service startup procedures.  
Thanks a lot, I will try this immediately after I return home.

---

<div class="post-metadata">

### Author: ![Gawan](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@Gawan](https://discourse.nodered.org/u/Gawan)
#### Post date: [22 October 2022 15:31 UTC](https://discourse.nodered.org/t/how-to-run-mosquitto-in-parallel-to-node-red-outside-local-mode/69423/6 "2022-10-22T15:31:37Z")

</div>

for anonymous access and I restarted it several times but as Colin mentioned below I never started the mosquitto as a service

---

<div class="post-metadata">

### Author: ![Gawan](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@Gawan](https://discourse.nodered.org/u/Gawan)
#### Post date: [22 October 2022 15:51 UTC](https://discourse.nodered.org/t/how-to-run-mosquitto-in-parallel-to-node-red-outside-local-mode/69423/7 "2022-10-22T15:51:01Z")

</div>

Ok, unfortunately no success

The service is running fine, even after restarting the Raspi:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/2/a2080a5d06fda15d9395686f113957198d66aa63.png)

This is how the CONF looks like:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/b/cb4862ac9fb4465122c69c5d6595b21aa311ae00.png)

But the MQTT explorer is unable to connect (although the raspberry itself CAN connect to the broker)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/2/b2c7ea83e966d0040ac567d63366e24125775661.png)

---

<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: [22 October 2022 16:20 UTC](https://discourse.nodered.org/t/how-to-run-mosquitto-in-parallel-to-node-red-outside-local-mode/69423/8 "2022-10-22T16:20:11Z")

</div>

Run  
`sudo tail -f /var/log/mosquitto/mosquitto.log`  
then in another terminal window  
`sudo systemctl restart mosquitto`  
Attempt to connect with MQTTExplorer, and post the log outputs from the mosquitto starting message.

---

<div class="post-metadata">

### Author: ![Gawan](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@Gawan](https://discourse.nodered.org/u/Gawan)
#### Post date: [24 October 2022 07:02 UTC](https://discourse.nodered.org/t/how-to-run-mosquitto-in-parallel-to-node-red-outside-local-mode/69423/9 "2022-10-24T07:02:21Z")

</div>

I did that, but unfortunately the output does not explain much.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/4/04cf69bf89237b5cbf9d6b68fb1feb0e950e35bd.png)

In green you can see when I restart the service  
In red you can see when I try to connect with MQTT Explorer from my Laptop

---

<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: [24 October 2022 08:19 UTC](https://discourse.nodered.org/t/how-to-run-mosquitto-in-parallel-to-node-red-outside-local-mode/69423/10 "2022-10-24T08:19:19Z")

</div>

In MQTT explorer did you intentionally select Encryption? De-select Encryption and try again.

---

<div class="post-metadata">

### Author: ![Gawan](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@Gawan](https://discourse.nodered.org/u/Gawan)
#### Post date: [25 October 2022 05:24 UTC](https://discourse.nodered.org/t/how-to-run-mosquitto-in-parallel-to-node-red-outside-local-mode/69423/11 "2022-10-25T05:24:20Z")

</div>

yes ... exactly this was the problem 🙂  
Thanks a lot, everything works fine now 😍

---

<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: [8 November 2022 05:25 UTC](https://discourse.nodered.org/t/how-to-run-mosquitto-in-parallel-to-node-red-outside-local-mode/69423/12 "2022-11-08T05:25:04Z")

</div>

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