# Tutor Forum Docker does not connect with mongoDB cluster

**URL:** <https://discuss.openedx.org/t/tutor-forum-docker-does-not-connect-with-mongodb-cluster/7483>\
**Category:** Development\
**Tags:** tutor\
**Created:** [June 13, 2022, 8:53am UTC](https://discuss.openedx.org/t/tutor-forum-docker-does-not-connect-with-mongodb-cluster/7483 "2022-06-13T08:53:26Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vamsi\_Kundla](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/vamsi_kundla/32/3797_2.png) [@Vamsi\_Kundla](https://discuss.openedx.org/u/Vamsi_Kundla)\
**Post date:** [June 13, 2022, 8:53am UTC](https://discuss.openedx.org/t/tutor-forum-docker-does-not-connect-with-mongodb-cluster/7483/1 "2022-06-13T08:53:26Z")

</div>

I am trying to connect the forum docker with MongoDB cluster.  
The configurations are -

> ```
> environment:
> SEARCH_SERVER: "http://elasticsearch:9200"      
> MONGODB_AUTH: "mongouser:password@"
> MONGODB_HOST: "mongo_primary_host_url"
> MONGODB_PORT: 27017
> MONGODB_DATABASE: "cs_comments_service"
> MONGOID_USE_SSL: true
> MONGOID_SSL_VERIFY: true
> MONGOID_READ_MODE: "primary"
> MONGOID_AUTH_MECH: ":mongodb_x509"
> MONGOID_SSL_CA_CERT: "My_certificate_path_in_the_forum_docker"
> MONGOID_TIMEOUT: 10
> 
> ```

This is the error i get in the forum.

> tutor\_local-forum-1 | Waiting for mongodb/elasticsearch…  
> tutor\_local-forum-1 | 2022/06/13 08:47:46 Waiting for: tcp://mongo\_primary\_host\_url:27017  
> tutor\_local-forum-1 | 2022/06/13 08:47:46 Waiting for: [http://elasticsearch:9200](http://elasticsearch:9200)  
> tutor\_local-forum-1 | 2022/06/13 08:47:46 Connected to tcp://mongo\_primary\_host\_url:27017  
> tutor\_local-forum-1 | 2022/06/13 08:47:46 Received 200 from [http://elasticsearch:9200](http://elasticsearch:9200)  
> tutor\_local-forum-1 | W, [2022-06-13T08:47:47.948442 #17] WARN – : Overwriting existing field \_id in class User.  
> tutor\_local-forum-1 | W, [2022-06-13T08:47:47.977085 #17] WARN – : MONGODB | Unsupported client option ‘max\_retries’. It will be ignored.  
> tutor\_local-forum-1 | W, [2022-06-13T08:47:47.977157 #17] WARN – : MONGODB | Unsupported client option ‘retry\_interval’. It will be ignored.  
> tutor\_local-forum-1 | W, [2022-06-13T08:47:47.977173 #17] WARN – : MONGODB | Unsupported client option ‘timeout’. It will be ignored.  
> tutor\_local-forum-1 | /app/cs\_comments\_service/vendor/bundle/ruby/2.5.0/gems/mongo-2.5.3/lib/mongo/server\_selector/selectable.rb:110:in `select_server': No server is available matching preference: #<Mongo::ServerSelector::Primary:0x47181947531780 tag_sets=[] max_staleness=nil> using server_selection_timeout=30 and local_threshold=0.015 (Mongo::Error::NoServerAvailable) tutor_local-forum-1 | from /app/cs_comments_service/vendor/bundle/ruby/2.5.0/gems/mongo-2.5.3/lib/mongo/collection/view/iterable.rb:41:in `block in each’  
> tutor\_local-forum-1 | from /app/cs\_comments\_service/vendor/bundle/ruby/2.5.0/gems/mongo-2.5.3/lib/mongo/retryable.rb:44:in `read_with_retry' tutor_local-forum-1 | from /app/cs_comments_service/vendor/bundle/ruby/2.5.0/gems/mongo-2.5.3/lib/mongo/collection/view/iterable.rb:40:in `each’  
> tutor\_local-forum-1 | from /app/cs\_comments\_service/vendor/bundle/ruby/2.5.0/gems/mongoid-7.0.5/lib/mongoid/query\_cache.rb:227:in `each' tutor_local-forum-1 | from /app/cs_comments_service/app.rb:175:in `map’  
> tutor\_local-forum-1 | from /app/cs\_comments\_service/app.rb:175:in `<top (required)>' tutor_local-forum-1 | from config/unicorn_tcp.rb:4:in `require’  
> tutor\_local-forum-1 | from config/unicorn\_tcp.rb:4:in `reload' tutor_local-forum-1 | from /app/cs_comments_service/vendor/bundle/ruby/2.5.0/gems/unicorn-5.3.1/lib/unicorn/configurator.rb:84:in `instance\_eval’  
> tutor\_local-forum-1 | from /app/cs\_comments\_service/vendor/bundle/ruby/2.5.0/gems/unicorn-5.3.1/lib/unicorn/configurator.rb:84:in `reload' tutor_local-forum-1 | from /app/cs_comments_service/vendor/bundle/ruby/2.5.0/gems/unicorn-5.3.1/lib/unicorn/configurator.rb:77:in `initialize’  
> tutor\_local-forum-1 | from /app/cs\_comments\_service/vendor/bundle/ruby/2.5.0/gems/unicorn-5.3.1/lib/unicorn/http\_server.rb:77:in `new' tutor_local-forum-1 | from /app/cs_comments_service/vendor/bundle/ruby/2.5.0/gems/unicorn-5.3.1/lib/unicorn/http_server.rb:77:in `initialize’  
> tutor\_local-forum-1 | from /app/cs\_comments\_service/vendor/bundle/ruby/2.5.0/gems/unicorn-5.3.1/bin/unicorn:126:in `new' tutor_local-forum-1 | from /app/cs_comments_service/vendor/bundle/ruby/2.5.0/gems/unicorn-5.3.1/bin/unicorn:126:in `\<top (required)\>’  
> tutor\_local-forum-1 | from ./bin/unicorn:16:in `load' tutor_local-forum-1 | from ./bin/unicorn:16:in `’

The same cluster is used for lms/cms. That works fine, but the forum does not connect.

---

<div class="post-metadata">

**Author:** ![ghassan](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/ghassan/32/2779_2.png) [@ghassan](https://discuss.openedx.org/u/ghassan)\
**Post date:** [June 13, 2022, 9:49am UTC](https://discuss.openedx.org/t/tutor-forum-docker-does-not-connect-with-mongodb-cluster/7483/2 "2022-06-13T09:49:44Z")

</div>

Hi

Could you specify which version of tutor/tutor-forum are you using?

On the other hand, I think tutor k8s patchs expects MONGODB\_USERNAME and MONGODB\_PASSWORD in env to to set MONGODB\_AUTH. I might be wrong, anyway my specualtion is based on this: [tutor-forum/k8s-deployments at master · overhangio/tutor-forum · GitHub](https://github.com/overhangio/tutor-forum/blob/master/tutorforum/patches/k8s-deployments#L29) .

---

<div class="post-metadata">

**Author:** ![Vamsi\_Kundla](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/vamsi_kundla/32/3797_2.png) [@Vamsi\_Kundla](https://discuss.openedx.org/u/Vamsi_Kundla)\
**Post date:** [June 13, 2022, 9:56am UTC](https://discuss.openedx.org/t/tutor-forum-docker-does-not-connect-with-mongodb-cluster/7483/3 "2022-06-13T09:56:12Z")

</div>

Hi,

> tutor==13.0.0  
> tutor-forum==13.0.0

This is a tutor local setup not k8s. The local setup is connected to a mongodb cluster.

---

<div class="post-metadata">

**Author:** ![ghassan](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/ghassan/32/2779_2.png) [@ghassan](https://discuss.openedx.org/u/ghassan)\
**Post date:** [June 13, 2022, 9:58am UTC](https://discuss.openedx.org/t/tutor-forum-docker-does-not-connect-with-mongodb-cluster/7483/4 "2022-06-13T09:58:50Z")

</div>

It’s same even for local setup, tutor-forum expects

> [@ghassan](#):
>
> MONGODB\_USERNAME and MONGODB\_PASSWORD in env to to set MONGODB\_AUTH

hence: [https://github.com/overhangio/tutor-forum/blob/49d9a49d2544bc55ba61598ee7463c1a35352622/tutorforum/patches/local-docker-compose-jobs-services#L5](https://github.com/overhangio/tutor-forum/blob/49d9a49d2544bc55ba61598ee7463c1a35352622/tutorforum/patches/local-docker-compose-jobs-services#L5)

---

<div class="post-metadata">

**Author:** ![Vamsi\_Kundla](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/vamsi_kundla/32/3797_2.png) [@Vamsi\_Kundla](https://discuss.openedx.org/u/Vamsi_Kundla)\
**Post date:** [June 13, 2022, 10:15am UTC](https://discuss.openedx.org/t/tutor-forum-docker-does-not-connect-with-mongodb-cluster/7483/5 "2022-06-13T10:15:09Z")

</div>

Hi,

Changed the MONGODB\_AUTH to MONGODB\_USERNAME and MONGODB\_PASSWORD.

> MONGODB\_USERNAME: “username”  
> MONGODB\_PASSWORD: “password”  
> …

The same issue persists.

---

<div class="post-metadata">

**Author:** ![ghassan](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/ghassan/32/2779_2.png) [@ghassan](https://discuss.openedx.org/u/ghassan)\
**Post date:** [June 13, 2022, 10:23am UTC](https://discuss.openedx.org/t/tutor-forum-docker-does-not-connect-with-mongodb-cluster/7483/6 "2022-06-13T10:23:47Z")

</div>

Can you let me know the steps you did to run tutor and tutor-forum so I can try reproduce your error or see if there was an issue in the steps

---

<div class="post-metadata">

**Author:** ![Vamsi\_Kundla](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/vamsi_kundla/32/3797_2.png) [@Vamsi\_Kundla](https://discuss.openedx.org/u/Vamsi_Kundla)\
**Post date:** [June 13, 2022, 10:37am UTC](https://discuss.openedx.org/t/tutor-forum-docker-does-not-connect-with-mongodb-cluster/7483/7 "2022-06-13T10:37:10Z")

</div>

Take a fresh env and install tutor and tutor-forum. Create a cluster of mongdb with 3 nodes(1 primary and 2 secondary).

Connect the tutor and forum with the cluster. For tutor we can create a patch for the changes in `production.py` file(Both CMS and LMS).  
Try and connect the tutor-forum also with the mongodb cluster.

Production.py(cms & lms) mongodb parameters.

> mongodb\_parameters = {  
> “host”: [“ip1:27017”, “ip2:27017”, “ip3:27017”],  
> “replicaSet”:‘rs0’,  
> “user”: “username”,  
> “password”: “password”,  
> “ssl”: True,  
> “tls”: True,  
> “tlsCAFile”: “path\_to\_crt\_in\_the\_lms\_or\_cms\_docker”,  
> “db”: “openedx”  
> }

The mongodb has ssl/tls authentication enabled(Cannot disable it).

---

<div class="post-metadata">

**Author:** ![ghassan](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/ghassan/32/2779_2.png) [@ghassan](https://discuss.openedx.org/u/ghassan)\
**Post date:** [June 13, 2022, 11:19am UTC](https://discuss.openedx.org/t/tutor-forum-docker-does-not-connect-with-mongodb-cluster/7483/8 "2022-06-13T11:19:12Z")

</div>

Unfortuetnly I haven’t done that before:

> [@Vamsi\_Kundla](#):
>
> Create a cluster of mongdb with 3 nodes(1 primary and 2 secondary).

Also regarding `MONGOID_AUTH_MECH` value could you try while setting it to “:scram” instead of “:mongodb\_x509”. Because this I think what the forum/comments typically uses.

---

<div class="post-metadata">

**Author:** ![Vamsi\_Kundla](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/vamsi_kundla/32/3797_2.png) [@Vamsi\_Kundla](https://discuss.openedx.org/u/Vamsi_Kundla)\
**Post date:** [June 13, 2022, 11:24am UTC](https://discuss.openedx.org/t/tutor-forum-docker-does-not-connect-with-mongodb-cluster/7483/9 "2022-06-13T11:24:44Z")

</div>

> [@ghassan](#):
>
> Unfortuetnly I haven’t dont that before:

Technically it is called replication(not clustering…my mistake) and it is not that hard. Just need three mongodb nodes running with replSet enabled. [https://www.mongodb.com/docs/manual/core/replica-set-secondary/](https://www.mongodb.com/docs/manual/core/replica-set-secondary/)  
[https://www.mongodb.com/docs/manual/tutorial/deploy-replica-set/](https://www.mongodb.com/docs/manual/tutorial/deploy-replica-set/)

> [@ghassan](#):
>
> Also regarding `MONGOID_AUTH_MECH` value could you try while setting it to “:scram” instead of “:mongodb\_x509”. Because this I think what the forum/comments typically uses.

I tried both of them. Same error.

---

<div class="post-metadata">

**Author:** ![ghassan](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/ghassan/32/2779_2.png) [@ghassan](https://discuss.openedx.org/u/ghassan)\
**Post date:** [June 13, 2022, 11:55am UTC](https://discuss.openedx.org/t/tutor-forum-docker-does-not-connect-with-mongodb-cluster/7483/10 "2022-06-13T11:55:49Z")

</div>

Since this seems an issue or a bug, with no simple or clear solution. Could please open an issue at [Issues · overhangio/tutor-forum · GitHub](https://github.com/overhangio/tutor-forum/issues) in the issue add the steps and log files. which I think you already stated here just the part about about creating replica/nodes is missing. Please be an explicit as possible.

As a maintner of tutor-forum myself, I will try to fix/address your issue during this week.

---

<div class="post-metadata">

**Author:** ![Vamsi\_Kundla](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/vamsi_kundla/32/3797_2.png) [@Vamsi\_Kundla](https://discuss.openedx.org/u/Vamsi_Kundla)\
**Post date:** [June 14, 2022, 12:35pm UTC](https://discuss.openedx.org/t/tutor-forum-docker-does-not-connect-with-mongodb-cluster/7483/11 "2022-06-14T12:35:06Z")

</div>

Hey @ghassan,

I opened and issue in [github](https://github.com/overhangio/tutor-forum/issues/7).

Hope we can figure it out soon.  
Reach out if there is anything i can help with.

---

<div class="post-metadata">

**Author:** ![ghassan](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/ghassan/32/2779_2.png) [@ghassan](https://discuss.openedx.org/u/ghassan)\
**Post date:** [June 15, 2022, 12:20pm UTC](https://discuss.openedx.org/t/tutor-forum-docker-does-not-connect-with-mongodb-cluster/7483/12 "2022-06-15T12:20:43Z")

</div>

Yeah, I just commented on your issue.

---

<div class="post-metadata">

**Author:** ![KFC\_kenneth](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/kfc_kenneth/32/6327_2.png) [@KFC\_kenneth](https://discuss.openedx.org/u/KFC_kenneth)\
**Post date:** [January 8, 2024, 9:00am UTC](https://discuss.openedx.org/t/tutor-forum-docker-does-not-connect-with-mongodb-cluster/7483/13 "2024-01-08T09:00:23Z")

</div>

Hello @Vamsi_Kundla ,

May I know is it still have issue connect Atlas MongoDB cluster,  
MONGODB\_HOST: mongodb+srv:// Because I find “MongoDB is using SRV records, so we cannot wait for it to be ready” during tutor local launch. Does someone know the solution? The installation process can run to finish but access to [http://local.edly.io/](http://local.edly.io/) it show “Internal Server Error”

Warm regard
