Graylog Not connecting to mongodb

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. 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

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
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

8080/tcp 9000/tcp 9010/tcp 9200/tcp 27017/tcp

sudo semanage port -a -t http_port_t -p tcp 9000

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 [Hold down CTRL and link on link to open tips documents in a separate tab]

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

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. I created those and included them on my mongodb_uri and it connected to Mongodb. Thank you very much for the help.

1 Like

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