"NodeBB could not connect to your Mongo database" Error


  • GNU/Linux

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


  • Admin

    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.


  • GNU/Linux

    @baris yes I did both. But I do not quite understand what you mean by "The one you should use during "./nodebb setup" is the second one". Can you please elaborate.


  • Admin

    When you run ./nodebb setup it should ask you which database to use, the name of the database and the username/pwd for the database user. You should enter the values you used when creating the second user from the docs(the nodebb user)


  • GNU/Linux

    @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




Looks like your connection to NodeBB was lost, please wait while we try to reconnect.