# Openflow Unable To Connect To Mongo DB

**URL:** <https://discourse.openiap.io/t/openflow-unable-to-connect-to-mongo-db/1897>\
**Category:** OpenCore\
**Created:** [November 8, 2024, 6:30pm UTC](https://discourse.openiap.io/t/openflow-unable-to-connect-to-mongo-db/1897 "2024-11-08T18:30:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kysluss](https://discourse.openiap.io/letter_avatar_proxy/v4/letter/k/77aa72/32.png) [@Kysluss](https://discourse.openiap.io/u/Kysluss)\
**Post date:** [November 8, 2024, 6:30pm UTC](https://discourse.openiap.io/t/openflow-unable-to-connect-to-mongo-db/1897/1 "2024-11-08T18:30:39Z")

</div>

Hello,

For some reason today, Openflow is throwing an error that is cannot connect to its MongoDB instance. This results in Openflow not fully starting and always giving a “Bad Gateway” error.

I’ll attach the logs from OpenFlow and MongoDB for review, but hoping you can help point me in the right direction. I have tried re-installing Docker and doing a fresh install of OpenRPA/OpenIAP using normal-up as well as restoring my computer to a previous backup where this was working. Hoping you can shed some light on what is happening.

---

<div class="post-metadata">

**Author:** ![Kysluss](https://discourse.openiap.io/letter_avatar_proxy/v4/letter/k/77aa72/32.png) [@Kysluss](https://discourse.openiap.io/u/Kysluss)\
**Post date:** [November 8, 2024, 6:32pm UTC](https://discourse.openiap.io/t/openflow-unable-to-connect-to-mongo-db/1897/2 "2024-11-08T18:32:12Z")

</div>

I couldn’t upload straight log files, so I saved them with a json extension.

[OpenIAP Log.json](https://discourse.openiap.io/uploads/short-url/spJmhILxLWnhR8SRS1OqHwDEh90.json) (23.8 KB)  
[MongoDB Log.json](https://discourse.openiap.io/uploads/short-url/zfnp1cXdvsQnlfxMOD8R370xhx6.json) (747.4 KB)

---

<div class="post-metadata">

**Author:** ![Allan\_Zimmermann](https://discourse.openiap.io/user_avatar/discourse.openiap.io/allan_zimmermann/32/12_2.png) [@Allan\_Zimmermann](https://discourse.openiap.io/u/Allan_Zimmermann)\
**Post date:** [November 9, 2024, 10:11am UTC](https://discourse.openiap.io/t/openflow-unable-to-connect-to-mongo-db/1897/3 "2024-11-09T10:11:39Z")

</div>

Your MongoDB has lost its replica set config.  
It’s not going to be easy for me to try and explain what to do over the forum, so I will not try. But here is the overall process you need to go through:

1. Make sure you backup your database before you try anything. If mongodump is not working, then gzip the /data folder and save it locally so you can recover the data in case something goes wrong. (You can execute commands inside the MongoDB Docker instance with `docker exec` and then use `docker cp` to copy the dump file out.)
2. Once you have saved your files, try fixing the replica set. Comment out the dbsetup service in Docker Compose and manually try removing and re-adding the replica set. You may need to remove and re-add `--replSet rs0` from the mongodb service in your docker-compose file, while removing and rebuilding the replica set.
3. Once the replica set is up and running and no longer in read-only mode, make sure you schedule a job once in a while that calls db-backup.sh and ensure you backup the files in case something like this happens again.

---

<div class="post-metadata">

**Author:** ![Kysluss](https://discourse.openiap.io/letter_avatar_proxy/v4/letter/k/77aa72/32.png) [@Kysluss](https://discourse.openiap.io/u/Kysluss)\
**Post date:** [November 9, 2024, 3:14pm UTC](https://discourse.openiap.io/t/openflow-unable-to-connect-to-mongo-db/1897/4 "2024-11-09T15:14:31Z")

</div>

Thank you Allan. This is the reason why running db-backup.sh periodically is important.

---

<div class="post-metadata">

**Author:** ![system](https://discourse.openiap.io/uploads/default/original/2X/a/a1ca7b164ac9a826839704d9ac82c7b5e6bcf557.png) [@system](https://discourse.openiap.io/u/system)\
**Post date:** [November 12, 2024, 3:14pm UTC](https://discourse.openiap.io/t/openflow-unable-to-connect-to-mongo-db/1897/5 "2024-11-12T15:14:56Z")

</div>

Closed on November 12, 2024, 3:14pm UTC

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