# Error connecting to mongo db database

**URL:** <https://discourse.nodered.org/t/error-connecting-to-mongo-db-database/34932>\
**Category:** General\
**Created:** [28 October 2020 07:34 UTC](https://discourse.nodered.org/t/error-connecting-to-mongo-db-database/34932 "2020-10-28T07:34:16Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![bachloo.rahul](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bachloo.rahul](https://discourse.nodered.org/u/bachloo.rahul)\
**Post date:** [28 October 2020 07:34 UTC](https://discourse.nodered.org/t/error-connecting-to-mongo-db-database/34932/1 "2020-10-28T07:34:16Z")

</div>

I am using mongo db node inorder to connect to my mongodb database which is installed on my pc,but i am getting this error

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/a/1acbe248b3ec575141e2da6c81a7172db9bef336.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/c/1c3c238107da5f69d8ea109a37aa8515fd11e039.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/a/7a7e6a71dac77be6bd7c393590435b279503ef8f.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:** [28 October 2020 07:46 UTC](https://discourse.nodered.org/t/error-connecting-to-mongo-db-database/34932/2 "2020-10-28T07:46:17Z")

</div>

Are you using the standard mongodb node or a contrib one? please provide the complete name

Does the user/password defined in the node have authority to access the database?

Is NR running on the same machine as the database?

---

<div class="post-metadata">

**Author:** ![bachloo.rahul](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bachloo.rahul](https://discourse.nodered.org/u/bachloo.rahul)\
**Post date:** [28 October 2020 07:57 UTC](https://discourse.nodered.org/t/error-connecting-to-mongo-db-database/34932/3 "2020-10-28T07:57:35Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/4/24c4e0bc325ea286aa47d0689b2fc82cad9f1867.png)  
I am using standard mqtt node and while installing mongo db i have selected typical installation (default) one.Yes Node Red and mongodb are running on the same machine.the 2nd image is taken from google for just refrence purposes.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/5/15f8b43ab0eeb51ded64ac9b26b0642f7cb6a9e5.png)

```auto
[flows.json|attachment](upload://uwRBC43vaqp1Z2hOE8KrtAYLRyF.json) (4.3 KB) 

```

---

<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:** [28 October 2020 08:19 UTC](https://discourse.nodered.org/t/error-connecting-to-mongo-db-database/34932/4 "2020-10-28T08:19:27Z")

</div>

node-red-mongodb is a very old node. you should remove it and try with node-red-node-mongodb

---

<div class="post-metadata">

**Author:** ![bachloo.rahul](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bachloo.rahul](https://discourse.nodered.org/u/bachloo.rahul)\
**Post date:** [28 October 2020 08:30 UTC](https://discourse.nodered.org/t/error-connecting-to-mongo-db-database/34932/5 "2020-10-28T08:30:21Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/3/33a4878414f95574e92c9906e912663367d81aff.png)  
I am also not using mongodb node in my current flow but it is showing cannot delete thee old one. ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/5/5584471fc52dcbb5edddf35f6f5b87e253e6462a.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/0/70eadbdff5686dbbe3ce11e6919d1c675419a2d3.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:** [28 October 2020 08:35 UTC](https://discourse.nodered.org/t/error-connecting-to-mongo-db-database/34932/6 "2020-10-28T08:35:18Z")

</div>

You have to remove the existing mongoldb nodes from your flows and do a deploy.  
Next use the palette manager to remove node-red-mongodb.  
Do a deploy and click th link to remove the configuration for the node and deploy again

Once that is done you should be able to install node-red-node-mongodb.

---

<div class="post-metadata">

**Author:** ![bachloo.rahul](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bachloo.rahul](https://discourse.nodered.org/u/bachloo.rahul)\
**Post date:** [28 October 2020 08:37 UTC](https://discourse.nodered.org/t/error-connecting-to-mongo-db-database/34932/7 "2020-10-28T08:37:24Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/0/508dcfb1c01941ae2210c579b14c3fa06d8fb9ae.png)  
deployed done but then also it shows node in use

---

<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:** [28 October 2020 08:43 UTC](https://discourse.nodered.org/t/error-connecting-to-mongo-db-database/34932/8 "2020-10-28T08:43:01Z")

</div>

I updated my last post and you might have missed it. You need to remove the configuration nodes it setup.

In the sidebar, click on the 'configuration' icon (see image) and then delete any nodes that show with dashes around them (see image) then deploy again  
 ![Screen Shot 2020-10-28 at 4.41.27 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/5/95c653de2434d7e86fb840200ba9d98afc1e9caa.png)

---

<div class="post-metadata">

**Author:** ![bachloo.rahul](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bachloo.rahul](https://discourse.nodered.org/u/bachloo.rahul)\
**Post date:** [28 October 2020 08:49 UTC](https://discourse.nodered.org/t/error-connecting-to-mongo-db-database/34932/9 "2020-10-28T08:49:10Z")

</div>

Thanks done ,now which properties we need to set inorder for new node to properly communicate with mongodb database?  
can we set username and password as blank.?  
Suppose i made a database using mongodb compass dbname-test and inside it there is a collection/table name-uc11

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/b/db36bfc9bbbdafc02a745f4593afcefafe05a7a4.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:** [28 October 2020 08:56 UTC](https://discourse.nodered.org/t/error-connecting-to-mongo-db-database/34932/10 "2020-10-28T08:56:48Z")

</div>

Not having used Mongodb, I can't help you with that part. But if it is like other databases, you need a user/password to access it. I would try using a user/password you have setup to access the database.

---

<div class="post-metadata">

**Author:** ![bachloo.rahul](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bachloo.rahul](https://discourse.nodered.org/u/bachloo.rahul)\
**Post date:** [28 October 2020 09:01 UTC](https://discourse.nodered.org/t/error-connecting-to-mongo-db-database/34932/11 "2020-10-28T09:01:32Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/0/80b08611b7aebdf827a1f690847cd48915f0aca2.png)  
yes connected but not able to see data in mongodb compass  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/9/e9822ca61e6e4a1778894438833a1d6d8f03800c.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/6/669a75691926f4f038a4027031c858950792c0b5.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/a/7ab49eb752b8d2a3af1aa673c8f48b32365aae16.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:** [28 October 2020 09:03 UTC](https://discourse.nodered.org/t/error-connecting-to-mongo-db-database/34932/12 "2020-10-28T09:03:44Z")

</div>

`28 Oct 14:28:37 - MongoError: database name must be a string`  
What did you enter in the mongodb node as the database name?

---

<div class="post-metadata">

**Author:** ![bachloo.rahul](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bachloo.rahul](https://discourse.nodered.org/u/bachloo.rahul)\
**Post date:** [28 October 2020 09:04 UTC](https://discourse.nodered.org/t/error-connecting-to-mongo-db-database/34932/13 "2020-10-28T09:04:31Z")

</div>

uc11 as table name and test is database name

---

<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:** [28 October 2020 09:10 UTC](https://discourse.nodered.org/t/error-connecting-to-mongo-db-database/34932/14 "2020-10-28T09:10:22Z")

</div>

In a previous post you said:

> [@bachloo.rahul](#):
>
> Suppose i made a database using mongodb compass dbname-test and inside it there is a collection/table name-uc11

is uc11 the `table` name or the `database` name?

---

<div class="post-metadata">

**Author:** ![bachloo.rahul](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bachloo.rahul](https://discourse.nodered.org/u/bachloo.rahul)\
**Post date:** [28 October 2020 09:10 UTC](https://discourse.nodered.org/t/error-connecting-to-mongo-db-database/34932/15 "2020-10-28T09:10:45Z")

</div>

uc11 is table name

---

<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:** [28 October 2020 09:18 UTC](https://discourse.nodered.org/t/error-connecting-to-mongo-db-database/34932/16 "2020-10-28T09:18:26Z")

</div>

Did you enter the database name in the configuration?

---

<div class="post-metadata">

**Author:** ![bachloo.rahul](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bachloo.rahul](https://discourse.nodered.org/u/bachloo.rahul)\
**Post date:** [28 October 2020 09:20 UTC](https://discourse.nodered.org/t/error-connecting-to-mongo-db-database/34932/17 "2020-10-28T09:20:16Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/7/d72ad5880570536b608fef3f0140e5d91f68b514.png)  
thanks for support  
yes i can see data in mongodb shell using command db.uc11.find()  
i had a question how to use date picker node in node red dashboard for seeing data from a particurlar date to another?

---

<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:** [28 October 2020 09:57 UTC](https://discourse.nodered.org/t/error-connecting-to-mongo-db-database/34932/18 "2020-10-28T09:57:34Z")

</div>

> [@bachloo.rahul](#):
>
> i had a question how to use date picker node in node red dashboard for seeing data from a particurlar date to another?

You should open another thread for this.

Is the log still showing db name error?

---

<div class="post-metadata">

**Author:** ![bachloo.rahul](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bachloo.rahul](https://discourse.nodered.org/u/bachloo.rahul)\
**Post date:** [28 October 2020 10:00 UTC](https://discourse.nodered.org/t/error-connecting-to-mongo-db-database/34932/19 "2020-10-28T10:00:40Z")

</div>

@zenofmud i think maybe that was becoz of my node red instance stopped running while i was injecting manually,so it was showing db name error.after that i restarted my node red instance then it worked correctly.

---

<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:** [27 December 2020 10:00 UTC](https://discourse.nodered.org/t/error-connecting-to-mongo-db-database/34932/20 "2020-12-27T10:00:53Z")

</div>

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