# Mongodb connection to local mongodb installation

**URL:** <https://forum.inductiveautomation.com/t/mongodb-connection-to-local-mongodb-installation/84322>\
**Category:** Ignition\
**Created:** [January 16, 2024, 1:42pm UTC](https://forum.inductiveautomation.com/t/mongodb-connection-to-local-mongodb-installation/84322 "2024-01-16T13:42:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![chaoliang](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@chaoliang](https://forum.inductiveautomation.com/u/chaoliang)\
**Post date:** [January 16, 2024, 1:42pm UTC](https://forum.inductiveautomation.com/t/mongodb-connection-to-local-mongodb-installation/84322/1 "2024-01-16T13:42:00Z")

</div>

the following link is for connection to mongodb cloud  
[https://docs.inductiveautomation.com/display/DOC81/MongoDB#MongoDB-ConnectingtoMongoDB](https://docs.inductiveautomation.com/display/DOC81/MongoDB#MongoDB-ConnectingtoMongoDB)

Is it possible to connect to mongodb local installation?

I tried to install it, create user and password, but it shows "faulted" after setup.  
I can use the same setup on mongodb compass to connect.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/6/f684abff40335b47b5751f122ea611ea6e1604e6.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 16, 2024, 5:13pm UTC](https://forum.inductiveautomation.com/t/mongodb-connection-to-local-mongodb-installation/84322/2 "2024-01-16T17:13:16Z")

</div>

Is there any actual error in your gateway logs?

---

<div class="post-metadata">

**Author:** ![kcollins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kcollins/32/19646_2.png) [@kcollins](https://forum.inductiveautomation.com/u/kcollins)\
**Post date:** [January 16, 2024, 6:00pm UTC](https://forum.inductiveautomation.com/t/mongodb-connection-to-local-mongodb-installation/84322/3 "2024-01-16T18:00:18Z")

</div>

If you're using MongoDB locally, make sure that you've created the target database first. You'll likely need to insert some data in order for it to be created. I used `mongosh` to perform this bootstrapping in the example below:

---

<div class="post-metadata">

**Author:** ![chaoliang](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@chaoliang](https://forum.inductiveautomation.com/u/chaoliang)\
**Post date:** [January 17, 2024, 12:44am UTC](https://forum.inductiveautomation.com/t/mongodb-connection-to-local-mongodb-installation/84322/4 "2024-01-17T00:44:45Z")

</div>

I imported this example database from the following web link, and created multiple users.  
([MongoDB Queries - Google Drive](https://drive.google.com/drive/folders/1XqnNv5msuluuX5JV50sGYC0Uvwa7w2C2))  
I have tried all users and different database, none of them work.

I will follow your video and have another try.

Thanks

---

<div class="post-metadata">

**Author:** ![chaoliang](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@chaoliang](https://forum.inductiveautomation.com/u/chaoliang)\
**Post date:** [January 17, 2024, 12:48am UTC](https://forum.inductiveautomation.com/t/mongodb-connection-to-local-mongodb-installation/84322/5 "2024-01-17T00:48:09Z")

</div>

Didn't find any error log.

---

<div class="post-metadata">

**Author:** ![chaoliang](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@chaoliang](https://forum.inductiveautomation.com/u/chaoliang)\
**Post date:** [January 17, 2024, 7:18am UTC](https://forum.inductiveautomation.com/t/mongodb-connection-to-local-mongodb-installation/84322/6 "2024-01-17T07:18:21Z")

</div>

I had a try again.

1. I installed a mongodb instance on the machine
2. I downloaded mongosh
3. I created a db called "gfg", and inserted a few document.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/4/a41b725fe3a433d57d4c550c0dbe36e9453a2bef.png)
4. I created a user "root", password "password" under "gfg" db.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/8/28f86be018275d5d8914995c0c7ec8e6ccff0d50.png)
5. I created a new mongo connector.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/c/3cd7cd9dffc9b75f5aa15f7925114ab4877c0692.png)
6. but it is still showing faulted.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/6/e67e37d124a5b59046803030acd91b3042eedc87.png)
7. I am testing it using maker edition. does it matter?
8. I tried the same connection Hosts as in the video "mongo", it didn't work either.
9. The port 27017 is open.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/6/d6c971567a419e59109d577752ebcce94e8bb15f.png)
10. there's no alarm in the logs.
11. I can run some python script to retrieve the values.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/2/322c5135c76b80fdf570952cab6cbbedd7e651fb.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/0/50f98efb99af74ccf9d5dca6ba6eab9819911c1c.png)

Not sure what is the next step from ignition part?

---

<div class="post-metadata">

**Author:** ![chaoliang](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@chaoliang](https://forum.inductiveautomation.com/u/chaoliang)\
**Post date:** [January 17, 2024, 7:33am UTC](https://forum.inductiveautomation.com/t/mongodb-connection-to-local-mongodb-installation/84322/7 "2024-01-17T07:33:04Z")

</div>

I think I found the problem.

The created user has to be under "admin" database.

1. I created a user "root" under "gfg" database, I can use the set credential to login mongo compass, but not the mongoDB connector.
2. I created a user "root1" under "admin" database, I can login both the mongo compass and the mongoDB connector in Ignition with this credential.
