Unable to connect to a remote mongodb server

Solved Technical Support
  • I am unable to connect to a remote mongodb server while setting up a fresh nodebb instance. I have verified connection manually through "mongo" command as seen below;

    [email protected]:~/nodebb$ mongo "mongodb://"
    MongoDB shell version v5.0.5
    connecting to: mongodb://
    Implicit session: session { "id" : UUID("b2adf492-0114-4e2a-8866-dc4fbde03ddd") }
    MongoDB server version: 5.0.5
    Warning: the "mongo" shell has been superseded by "mongosh",
    which delivers improved usability and compatibility.The "mongo" shell has been deprecated and will be removed in
    an upcoming release.
    For installation instructions, see

    Netcat is also successful, please see below;

    [email protected]:~/nodebb$ nc -zv 27017
    Connection to 27017 port [tcp/*] succeeded!

    However, this is how it ends up while running nodebb setup. I have also tried to manually create "config.json" and including only "mongo" details, however, it ended up giving me the same error. This was a suggestion on one of the past posts. I have tried with both "nodebb" user and as well as the "admin" user - both having different password setups.

    Any idea what I could be doing wrong?


    [email protected]:~/nodebb$ ./nodebb setup
    2021-12-27T05:51:37.566Z [1198] - info: NodeBB Setup Triggered via Command Line
    Welcome to NodeBB v1.18.6!
    This looks like a new installation, so you'll have to answer a few questions about your environment before we can proceed.
    Press enter to accept the default setting (shown in brackets).
    URL used to access this NodeBB (http://localhost:4567) 
    Please enter a NodeBB secret (8c340dbe-d515-425a-953f-2442af87307e) 
    Would you like to submit anonymous plugin usage to nbbpm? (yes) 
    Which database to use (mongo) 
    2021-12-27T05:51:41.129Z [1198] - info: 
    Now configuring mongo database:
    MongoDB connection URI: (leave blank if you wish to specify host, port, username/password and database individually)
    Format: mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]] 
    Host IP or address of your MongoDB instance (
    Host port of your MongoDB instance (27017) 
    MongoDB username nodebb
    Password of your MongoDB database 
    MongoDB database name (nodebb) 
    2021-12-27T05:52:01.863Z [1198] - warn: NodeBB Setup Aborted.
     MongoServerError: Authentication failed.
        at MessageStream.messageHandler (/home/fsuzer/nodebb/node_modules/mongodb/lib/cmap/connection.js:467:30)
        at MessageStream.emit (node:events:390:28)
        at processIncomingData (/home/fsuzer/nodebb/node_modules/mongodb/lib/cmap/message_stream.js:108:16)
        at MessageStream._write (/home/fsuzer/nodebb/node_modules/mongodb/lib/cmap/message_stream.js:28:9)
        at writeOrBuffer (node:internal/streams/writable:389:12)
        at _write (node:internal/streams/writable:330:10)
        at MessageStream.Writable.write (node:internal/streams/writable:334:10)
        at Socket.ondata (node:internal/streams/readable:754:22)
        at Socket.emit (node:events:390:28)
        at addChunk (node:internal/streams/readable:315:12)
  • It like like you used a URI to collect with the mongo shell. Why not use a URI with NodeBB as well? I suggest trying that.

  • Hi @pitaj

    Thanks for the suggestion, it worked!

  • F FreeWorLD has marked this topic as solved on

Suggested Topics