ERROR: Unable to connect to MongoDB. Is it running and the configuration correct?


(Satesh Pawaroo) #1

I recently moved to Graylog v2.4.5 and only have one appliance with a single mongodb instance. For some reason we are not able to get to main site to login and in the logs I see connection errors:

2018-06-27_19:36:25.42538 ERROR [CmdLineTool] Guice error (more detail on log level debug): Error injecting constructor, com.mongodb.MongoCommandException: Command failed with error 13: ‘not authorized on graylog to execute command { createIndexes: “roles”, indexes: [ { key: { name_lower: 1 }, name: “name_lower_1”, ns: “graylog.roles”, unique: true } ] }’ on server 127.0.0.1:27017. The full response is { “ok” : 0.0, “errmsg” : “not authorized on graylog to execute command { createIndexes: “roles”, indexes: [ { key: { name_lower: 1 }, name: “name_lower_1”, ns: “graylog.roles”, unique: true } ] }”, “code” : 13, “codeName” : “Unauthorized” }

I have another installation and after the upgrade we are good and didn’t have any issues connecting.


(Jan Doberstein) #2

Command failed with error 13: ‘not authorized on graylog to execute command

Did you create user with password for Graylog in your MongoDB? If yes, check the roles you assign to this user.

http://docs.graylog.org/en/2.4/pages/configuration/multinode_setup.html#mongodb-replica-set

Gives you the following quote:

which has the roles readWrite and dbAdmin.


#3

Make sure under graylog.conf you have your credentials in your mongodb connection string.

Eg : username:password@mongoip:port/database


(Satesh Pawaroo) #4

I have verified that I included the string in the graylog.conf file. I am still seeing the same error in the logs. I also verified that the user has the right access on they graylog database on mongodb. I tried updating the password but still not able to connect.


(Jochen) #5

What’s in the configuration file exactly? (Replace the username with “USER” and the password with “PASS” respectively)

Are you sure? How did you verify that exactly and what was the complete output of the command in the MongoDB shell?


(Satesh Pawaroo) #6

use admin
switched to db admin
db.auth(“grpadmin”, “**********” )
1
show databases
admin 0.000GB
graylog 0.009GB
local 0.000GB
switch graylog
use graylog
switched to db graylog
show users
{
“_id” : “graylog.admin”,
“user” : “admin”,
“db” : “graylog”,
“roles” : [
{
“role” : “dbAdmin”,
“db” : “graylog”
},
{
“role” : “readWrite”,
“db” : “graylog”
}
]
}
{
“_id” : “graylog.goofy”,
“user” : “goofy”,
“db” : “graylog”,
“roles” : [
{
“role” : “dbAdmin”,
“db” : “graylog”
},
{
“role” : “readWrite”,
“db” : “graylog”
}
]
}
{
“_id” : “graylog.grpadmin”,
“user” : “grpadmin”,
“db” : “graylog”,
“roles” : [
{
“role” : “dbAdmin”,
“db” : “graylog”
}
]
}
{
“_id” : “graylog.vscan2”,
“user” : “vscan2”,
“db” : “graylog”,
“roles” : [
{
“role” : “dbAdmin”,
“db” : “graylog”
},
{
“role” : “readWrite”,
“db” : “graylog”
}
]
}


(Satesh Pawaroo) #7

I stared out my password but you see the output. I also tried removing the username and add USER and removed password as PASS but still not to connect.


(system) #8

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