# Graylog Not connecting to mongodb

**URL:** <https://community.graylog.org/t/graylog-not-connecting-to-mongodb/34953>\
**Category:** Graylog Central (peer support)\
**Created:** [February 17, 2025, 11:59am UTC](https://community.graylog.org/t/graylog-not-connecting-to-mongodb/34953 "2025-02-17T11:59:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Smiles](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/smiles/32/17644_2.png) [@Smiles](https://community.graylog.org/u/Smiles)\
**Post date:** [February 17, 2025, 11:59am UTC](https://community.graylog.org/t/graylog-not-connecting-to-mongodb/34953/1 "2025-02-17T11:59:33Z")

</div>

Before you post: Your responses to these questions will help the community help you. Please complete this template if you’re asking a support question.  
**Don’t forget to select tags to help index your topic!**

**1. Describe your incident:**  
I am new to Graylog. I have installed Graylog as per the steps at [Red Hat Installation](https://go2docs.graylog.org/current/downloading_and_installing_graylog/red_hat_installation.htm). However, it seems like it is not working as expected with mongo db in Replica set. So, basically, what I am trying to achieve is redundancy. Such that if one server fails, we have a backup server.

Main: 172.29.164.165  
Backup: 10.184.162.145

However, it seems like Graylog is not connecting with the mongodb server. When I start Graylog, I get the following continuous error message:  
svdt1graylog ~]$ **tail -f /var/log/graylog-server/server.log**  
2025-02-17T14:23:33.956+03:00 INFO [MongoDBPreflightCheck] MongoDB is not available. Retry #46510  
2025-02-17T14:23:35.956+03:00 INFO [MongoDBPreflightCheck] MongoDB is not available. Retry #46511  
2025-02-17T14:23:37.957+03:00 INFO [MongoDBPreflightCheck] MongoDB is not available. Retry #46512  
2025-02-17T14:23:39.957+03:00 INFO [MongoDBPreflightCheck] MongoDB is not available. Retry #46513  
2025-02-17T14:23:41.958+03:00 INFO [MongoDBPreflightCheck] MongoDB is not available. Retry #46514  
2025-02-17T14:23:43.958+03:00 INFO [MongoDBPreflightCheck] MongoDB is not available. Retry #46515  
2025-02-17T14:23:45.959+03:00 INFO [MongoDBPreflightCheck] MongoDB is not available. Retry #46516  
2025-02-17T14:23:47.959+03:00 INFO [MongoDBPreflightCheck] MongoDB is not available. Retry #46517  
2025-02-17T14:23:49.959+03:00 INFO [MongoDBPreflightCheck] MongoDB is not available. Retry #46518  
2025-02-17T14:23:51.960+03:00 INFO [MongoDBPreflightCheck] MongoDB is not available. Retry #46519  
2025-02-17T14:23:53.960+03:00 INFO [MongoDBPreflightCheck] MongoDB is not available. Retry #46520

Therefore, Graylog is not binding to port 9000.  
Here is my setup:  
server configurations

```auto
is_leader = true
node_id_file = /etc/graylog/server/node-id
password_secret = ***********************
root_username = admin

root_password_sha2 = ***************
root_timezone = Africa/Nairobi
bin_dir = /usr/share/graylog-server/bin
data_dir = /var/lib/graylog-server
plugin_dir = /usr/share/graylog-server/plugin
http_bind_address = 172.29.164.16:9000
#http_bind_address = [2001:db8::1]:9000
allow_leading_wildcard_searches = false
allow_highlighting = false
field_value_suggestion_mode = on
output_batch_size = 500

output_flush_interval = 1

output_fault_count_threshold = 5
output_fault_penalty_seconds = 30
processor_wait_strategy = blocking

ring_size = 65536

inputbuffer_ring_size = 65536
inputbuffer_wait_strategy = blocking

message_journal_enabled = true
message_journal_dir = /var/lib/graylog-server/journal
lb_recognition_period_seconds = 3

mongodb_uri = mongodb://172.29.164.165,10.184.162.145/graylog?replicaSet=graylogs_mongodb
mongodb_max_connections = 1000
integrations_scripts_dir = /usr/share/graylog-server/scripts

```

```auto
sudo systemctl status mongod

```

MongoDb configurations are okay and the primary and secondary sets are working well with  
Despite everything being up the port is still not binding to Graylog therefore, the server is not listening to the port

sudo firewall-cmd --list-ports | grep 9000

```auto
8080/tcp 9000/tcp 9010/tcp 9200/tcp 27017/tcp

```

sudo semanage port -a -t http\_port\_t -p tcp 9000

```auto
Port tcp/9000 already defined, modifying instead

```

**2. Describe your environment:**

- OS Information: Redhat 9.5

- Package Version:Graylog 6

**3. What steps have you already taken to try and solve the problem?**  
I have enabled the port with firewalld  
Restarted my VM server  
Reinstalled Graylog and Graylog data node

**4. How can the community help?**

How can I get Graylog to connect with Replicaset Mongodb setup.

**Helpful Posting Tips:** [Tips for Posting Questions that Get Answers](https://community.graylog.org/t/tips-for-posting-questions-that-get-answers/21828) [Hold down CTRL and link on link to open tips documents in a separate tab]

---

<div class="post-metadata">

**Author:** ![Joel\_Duffield](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@Joel\_Duffield](https://community.graylog.org/u/Joel_Duffield)\
**Post date:** [February 17, 2025, 1:32pm UTC](https://community.graylog.org/t/graylog-not-connecting-to-mongodb/34953/2 "2025-02-17T13:32:43Z")

</div>

Can you connect to both mongodb servers from each server with mongosh (the mongo client) as in connect to both locsl and remote.

---

<div class="post-metadata">

**Author:** ![Smiles](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/smiles/32/17644_2.png) [@Smiles](https://community.graylog.org/u/Smiles)\
**Post date:** [February 18, 2025, 2:39pm UTC](https://community.graylog.org/t/graylog-not-connecting-to-mongodb/34953/3 "2025-02-18T14:39:51Z")

</div>

Yes, they can connect. I realized that the issue was with the credentials. when creating a replica set, you will have to create authentication credentials as described here [https://go2docs.graylog.org/current/setting\_up\_graylog/multi-node\_setup.html](https://go2docs.graylog.org/current/setting_up_graylog/multi-node_setup.html). I created those and included them on my mongodb\_uri and it connected to Mongodb. Thank you very much for the help.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/graylog/original/3X/c/7/c7c09c6b5099570133d6502b83f50ba4430de5b6.png) [@system](https://community.graylog.org/u/system)\
**Post date:** [March 4, 2025, 2:39pm UTC](https://community.graylog.org/t/graylog-not-connecting-to-mongodb/34953/4 "2025-03-04T14:39:58Z")

</div>

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