# MongoDB integration with NodeRed

**URL:** <https://discourse.nodered.org/t/mongodb-integration-with-nodered/26422>\
**Category:** General\
**Created:** [10 May 2020 11:52 UTC](https://discourse.nodered.org/t/mongodb-integration-with-nodered/26422 "2020-05-10T11:52:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ElleshaHackett](https://avatars.discourse-cdn.com/v4/letter/e/8c91f0/32.png) [@ElleshaHackett](https://discourse.nodered.org/u/ElleshaHackett)\
**Post date:** [10 May 2020 11:52 UTC](https://discourse.nodered.org/t/mongodb-integration-with-nodered/26422/1 "2020-05-10T11:52:41Z")

</div>

I love this project. Using it a few days, so far without any problems till I tried to integrate MongoDB. I'm using Docker but I am totally lost by the lack of proper documentation. All docs seem outdated and the package names confusing. From my Docker host IP I can access everything, NodeRED and MongoDB but the only errors I get in NodeRED are `MongoNetworkError: failed to connect to server [XX:27017] on first connect [MongoError: Authentication failed.]" `. A network error seems logical but I highly doubt that is the issue here.

I suspect that the packages are outdated. I also pulled the latest image from MongoDB which is MongoDB 4.2.6. But its totally unclear if this could ever work with NodeRED. As I find packages:

node-red-contrib-mongodb  
node-red-contrib-mongodb2  
node-red-contrib-mongodb3  
node-red-contrib-mongodb-variable  
node-red-contrib-mongo-client  
node-red-node-mongodb  
node-red-mongodb

All with their own (outdated) documentation. This starts to get quite annoying now, I almost wasted one day of figuring out simply how to get NodeRED to communicate with MongoDB. What am I doing wrong? What package or configuration do I need? I almost tried all above packages in different configurations. I simply want to read and write stuff from/to MongoDB from NodeRED.

---

<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:** [10 May 2020 12:54 UTC](https://discourse.nodered.org/t/mongodb-integration-with-nodered/26422/2 "2020-05-10T12:54:19Z")

</div>

How are you addressing mongodb from node-red? For example, I believe you can't use localhost from within a container. Personally I only use Docker when there is a good reason, it just makes life complicated otherwise.

---

<div class="post-metadata">

**Author:** ![ElleshaHackett](https://avatars.discourse-cdn.com/v4/letter/e/8c91f0/32.png) [@ElleshaHackett](https://discourse.nodered.org/u/ElleshaHackett)\
**Post date:** [10 May 2020 14:37 UTC](https://discourse.nodered.org/t/mongodb-integration-with-nodered/26422/3 "2020-05-10T14:37:53Z")

</div>

Thanks for your reply. I tried different things like localhost, 127.0.0.1, the name of the Mongo container (using the internal DNS resolution in Docker), the Docker host IP 192.168.x.x.

Nothing worked, got annoyed after wasting almost a full day, switched to MySQL. Setup worked in less than 5 minutes.

---

<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:** [10 May 2020 14:45 UTC](https://discourse.nodered.org/t/mongodb-integration-with-nodered/26422/4 "2020-05-10T14:45:08Z")

</div>

I am surprised that you have a requirement that can be satisfied by either mysql or mongodb, they are very different tools.

---

<div class="post-metadata">

**Author:** ![ElleshaHackett](https://avatars.discourse-cdn.com/v4/letter/e/8c91f0/32.png) [@ElleshaHackett](https://discourse.nodered.org/u/ElleshaHackett)\
**Post date:** [10 May 2020 14:53 UTC](https://discourse.nodered.org/t/mongodb-integration-with-nodered/26422/5 "2020-05-10T14:53:24Z")

</div>

I am aware. I was planning to design something I had in mind entirely around MongoDB while most functions are perfectly suitable for SQL as well. I will just start off now with MySQL and only for a few things think of an alternative. It's not rocket science but it was more a trial case to actually start working more with MongoDB.

---

<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 July 2020 14:53 UTC](https://discourse.nodered.org/t/mongodb-integration-with-nodered/26422/6 "2020-07-09T14:53:32Z")

</div>

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