# MQTT mosquitto connection problem

**URL:** https://discourse.nodered.org/t/mqtt-mosquitto-connection-problem/46941
**Category:** General
**Created:** [9 June 2021 18:39 UTC](https://discourse.nodered.org/t/mqtt-mosquitto-connection-problem/46941 "2021-06-09T18:39:37Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![flayy](https://avatars.discourse-cdn.com/v4/letter/f/85f322/32.png) [@flayy](https://discourse.nodered.org/u/flayy)
#### Post date: [9 June 2021 18:39 UTC](https://discourse.nodered.org/t/mqtt-mosquitto-connection-problem/46941/1 "2021-06-09T18:39:38Z")

</div>

NR 1.3.5  
Node.js v12.21.0  
Ubuntu 21.04

```
trying to connect mqtt in and mqtt out nodes
MQTT broker is running correctly (tested by MQTT Explorer : localhost:1883)
credentials are typed in properly
yellow dot on both nodes (IN and OUT)

```

seems Node Red can't reach the server (localhost)

any advice?

tks

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [9 June 2021 18:42 UTC](https://discourse.nodered.org/t/mqtt-mosquitto-connection-problem/46941/2 "2021-06-09T18:42:57Z")

</div>

Is the broker and node-red on the same server?

What version of mosquito are you running?

---

<div class="post-metadata">

### Author: ![flayy](https://avatars.discourse-cdn.com/v4/letter/f/85f322/32.png) [@flayy](https://discourse.nodered.org/u/flayy)
#### Post date: [9 June 2021 18:44 UTC](https://discourse.nodered.org/t/mqtt-mosquitto-connection-problem/46941/3 "2021-06-09T18:44:03Z")

</div>

Yes same server  
Mosquitto 2.0.10

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [9 June 2021 18:44 UTC](https://discourse.nodered.org/t/mqtt-mosquitto-connection-problem/46941/4 "2021-06-09T18:44:57Z")

</div>

Show us the settings on the mqtt config node

---

<div class="post-metadata">

### Author: ![flayy](https://avatars.discourse-cdn.com/v4/letter/f/85f322/32.png) [@flayy](https://discourse.nodered.org/u/flayy)
#### Post date: [9 June 2021 19:01 UTC](https://discourse.nodered.org/t/mqtt-mosquitto-connection-problem/46941/6 "2021-06-09T19:01:39Z")

</div>

![Immagine 2021-06-09 205504](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/f/bf3ef1325482b98bad09cc53d437b875f1e26efa.jpeg)

---

<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: [9 June 2021 19:31 UTC](https://discourse.nodered.org/t/mqtt-mosquitto-connection-problem/46941/7 "2021-06-09T19:31:40Z")

</div>

Is node-red installed using Docker? If not then how did you install it?

---

<div class="post-metadata">

### Author: ![flayy](https://avatars.discourse-cdn.com/v4/letter/f/85f322/32.png) [@flayy](https://discourse.nodered.org/u/flayy)
#### Post date: [9 June 2021 20:02 UTC](https://discourse.nodered.org/t/mqtt-mosquitto-connection-problem/46941/8 "2021-06-09T20:02:22Z")

</div>

Yes Node-Red is installed using Docker. Node Red is working , I can reach using the server (localhost:1883) or by other client (IPAddress:1883). MQTT is running and tested by MQTT explorer installed into the server

---

<div class="post-metadata">

### Author: ![flayy](https://avatars.discourse-cdn.com/v4/letter/f/85f322/32.png) [@flayy](https://discourse.nodered.org/u/flayy)
#### Post date: [9 June 2021 20:06 UTC](https://discourse.nodered.org/t/mqtt-mosquitto-connection-problem/46941/9 "2021-06-09T20:06:31Z")

</div>

Here the MQTT Explorer

 ![MQTTExplorer](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/e/7ecf82b07a4c19c29860ea9dea60b2ae2c3d0dbe.png)

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [9 June 2021 20:20 UTC](https://discourse.nodered.org/t/mqtt-mosquitto-connection-problem/46941/10 "2021-06-09T20:20:53Z")

</div>

You should always mention docker when asking questions on this forum. It is quite often the reason for issues and saves everyone some time going down the wrong path.

So, localhost to node-red is not gonna be localhost to mosquito. Node-reds localhost will be its own container (not where mosquito is running)

Is mosquito installed directly on the computer or in another docker container?

Either way, you will likely need to access mosquito via ip address AND since it is ver2 you will need to modify its config to permit external connection.

Ps, out of curiosity, why are you using docker? If you are not familiar with docker networking and volume persistence etc this can be more effort than it is worth.

---

<div class="post-metadata">

### Author: ![flayy](https://avatars.discourse-cdn.com/v4/letter/f/85f322/32.png) [@flayy](https://discourse.nodered.org/u/flayy)
#### Post date: [9 June 2021 20:28 UTC](https://discourse.nodered.org/t/mqtt-mosquitto-connection-problem/46941/11 "2021-06-09T20:28:27Z")

</div>

Tks, now is clear.  
So if an application is into a docker, localhost is the docker itself.... got it.  
Mosquitto is not into a docker.

Actually, I use the docker installation because a lot of tutorials suggests to install in this way and I'm extremely new on Linux and Ubuntu so I'm trying to follow the online guides.

Tks so much, I'll try to configure Mosquitto to get external connection.

---

<div class="post-metadata">

### Author: ![flayy](https://avatars.discourse-cdn.com/v4/letter/f/85f322/32.png) [@flayy](https://discourse.nodered.org/u/flayy)
#### Post date: [9 June 2021 21:02 UTC](https://discourse.nodered.org/t/mqtt-mosquitto-connection-problem/46941/12 "2021-06-09T21:02:13Z")

</div>

Resolved!!  
Tks

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [9 June 2021 21:51 UTC](https://discourse.nodered.org/t/mqtt-mosquitto-connection-problem/46941/13 "2021-06-09T21:51:53Z")

</div>

> [@flayy](#):
>
> a lot of tutorials suggests to install in this way

Hi - any chance you can share those links ? so we can maybe try to get them corrected.

---

<div class="post-metadata">

### Author: ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)
#### Post date: [10 June 2021 02:10 UTC](https://discourse.nodered.org/t/mqtt-mosquitto-connection-problem/46941/14 "2021-06-10T02:10:54Z")

</div>

I installed Mosquitto on a spare Raspberry Pi3 and it has been running for years. Couldn't be simpler.

---

<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: [9 August 2021 02:10 UTC](https://discourse.nodered.org/t/mqtt-mosquitto-connection-problem/46941/15 "2021-08-09T02:10:57Z")

</div>

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