"NodeBB could not connect to your Mongo database" Error
-
I am getting the following error when executing "./nodebb setup" :
info: Now configuring mongo database: Configuration Saved OK
error: NodeBB could not connect to your Mongo database. Mongo returned the following error: Authentication failed.MongoError: Authentication failed.
at Function.MongoError.create (/home/countach/nodebb/node_modules/mongodb-core/lib/error.js:31:11)
at /home/countach/nodebb/node_modules/mongodb-core/lib/connection/pool.js:497:72
at authenticateStragglers (/home/countach/nodebb/node_modules/mongodb-core/lib/connection/pool.js:443:16)
at Connection.messageHandler (/home/countach/nodebb/node_modules/mongodb-core/lib/connection/pool.js:477:5)
at Socket.<anonymous> (/home/countach/nodebb/node_modules/mongodb-core/lib/connection/connection.js:321:22)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:547:20)I am able to connect to the mongo-shell using the same credentials.I am following the installation documented here and all goes well until I execute "./nodebb setup".
-
Did you do both of these?
> use admin > db.createUser( { user: "<Enter a username>", pwd: "<Enter a secure password>", roles: [ { role: "readWriteAnyDatabase", db: "admin" }, { role: "userAdminAnyDatabase", db: "admin" } ] } ) > use nodebb > db.createUser( { user: "nodebb", pwd: "<Enter a secure password>", roles: [ { role: "readWrite", db: "nodebb" }, { role: "clusterMonitor", db: "admin" } ] } )
The one you should use during
./nodebb setup
is the second one. -
@baris thats the thing I do not get that prompt to specify the DB, it attempts to connect automatically after ./nodebb setup is executed. Could it be the authentication settings? I have security authorization enabled in my mongod.conf ...
-
@countach said in "NodeBB could not connect to your Mongo database" Error:
@baris thats the thing I do not get that prompt to specify the DB, it attempts to connect automatically after ./nodebb setup is executed. Could it be the authentication settings? I have security authorization enabled in my mongod.conf ...
If you had an existing config.json, it will only try to fill in blanks. Try moving your config.json out of the way and running it again. It will have prompts like this...
7/7 01:07:24 [3009] - info: Now configuring mongo database:
Host IP or address of your MongoDB instance (127.0.0.1)
Host port of your MongoDB instance (27017)
MongoDB username
Password of your MongoDB database -
this command is not working plz help?
$ mongo -u admin -p MYPASSWORD --authenticationDatabase=adminERROR:
MongoDB shell version v4.0.9
connecting to: mongodb://127.0.0.1:27017/?authSource=nodebb&gssapiServiceName=mongodb
2019-04-15T19:18:33.313+0200 E QUERY [js] Error: Authentication failed. :
connect@src/mongo/shell/mongo.js:343:13
@(connect):2:6
exception: connect failed