# Unable to connect broker:mqtt and node-red

**URL:** https://discourse.nodered.org/t/unable-to-connect-broker-mqtt-and-node-red/62742
**Category:** General
**Tags:** mqtt
**Created:** [17 May 2022 10:58 UTC](https://discourse.nodered.org/t/unable-to-connect-broker-mqtt-and-node-red/62742 "2022-05-17T10:58:41Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Vineeth](https://avatars.discourse-cdn.com/v4/letter/v/ac8455/32.png) [@Vineeth](https://discourse.nodered.org/u/Vineeth)
#### Post date: [17 May 2022 10:58 UTC](https://discourse.nodered.org/t/unable-to-connect-broker-mqtt-and-node-red/62742/1 "2022-05-17T10:58:41Z")

</div>

I have installed mosquitto broker and Node red in my PC.  
I'm able to subscribe and publish messages.  
But in Node red i'm unable to connect to mqtt.

> **17 May 10:46:25 - [info] Starting flows**  
> **17 May 10:46:25 - [info] Started flows**  
> **17 May 10:46:25 - [info] [mqtt-broker:cb3902d2d36e9b73] Connection failed to broker: mqtt://localhost:1883**

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [17 May 2022 11:14 UTC](https://discourse.nodered.org/t/unable-to-connect-broker-mqtt-and-node-red/62742/2 "2022-05-17T11:14:47Z")

</div>

You might want to install MQTT Explorer if running Windows. You can then test a different connection to the broker. If that doesn't work, I would check the Mosquitto configuration and if that still doesn't turn up the issue, increase Mosquitto's logging level to see what the problem is.

---

<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: [17 May 2022 13:58 UTC](https://discourse.nodered.org/t/unable-to-connect-broker-mqtt-and-node-red/62742/3 "2022-05-17T13:58:49Z")

</div>

> [@Vineeth](#):
>
> 7 May 10:46:25 - [info] [mqtt-broker:cb3902d2d36e9b73] Connection failed to broker: mqtt://localhost:1883

Is NR running on the same device as mosquito? As is, you are trying to connect to a broker on the same device. If it is on another device, you need to specify the IP of the device running mosquito.

---

<div class="post-metadata">

### Author: ![Vineeth](https://avatars.discourse-cdn.com/v4/letter/v/ac8455/32.png) [@Vineeth](https://discourse.nodered.org/u/Vineeth)
#### Post date: [18 May 2022 05:25 UTC](https://discourse.nodered.org/t/unable-to-connect-broker-mqtt-and-node-red/62742/4 "2022-05-18T05:25:05Z")

</div>

Yes Node Red is running on the same device.  
I'm configuring Mqtt node server as localhost:1883

---

<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: [18 May 2022 07:39 UTC](https://discourse.nodered.org/t/unable-to-connect-broker-mqtt-and-node-red/62742/5 "2022-05-18T07:39:52Z")

</div>

> [@Vineeth](#):
>
> I'm able to subscribe and publish messages.

What is doing this subscribe and publish?  
What device is it on?  
Pease show it’s configuration  
Please shot the MQTT configuration in node-red

---

<div class="post-metadata">

### Author: ![Vineeth](https://avatars.discourse-cdn.com/v4/letter/v/ac8455/32.png) [@Vineeth](https://discourse.nodered.org/u/Vineeth)
#### Post date: [18 May 2022 09:37 UTC](https://discourse.nodered.org/t/unable-to-connect-broker-mqtt-and-node-red/62742/6 "2022-05-18T09:37:53Z")

</div>

Able to resolve it after running NodeRed in host networking mode.

---

<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: [18 May 2022 09:50 UTC](https://discourse.nodered.org/t/unable-to-connect-broker-mqtt-and-node-red/62742/7 "2022-05-18T09:50:54Z")

</div>

> [@Vineeth](#):
>
> resolve it after running NodeRed in host networking mode

So you are using Docker or a VM or some kind of container to run node-red?

This sort of information is really important when asking for help.

---

<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: [1 June 2022 09:51 UTC](https://discourse.nodered.org/t/unable-to-connect-broker-mqtt-and-node-red/62742/8 "2022-06-01T09:51:32Z")

</div>

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