MongoServerError: Authentication failed.

Unsolved Technical Support
  • [email protected]:~/nodebb$ ./nodebb start
    2022-06-01T07:14:30.498Z [137319] - info: Launching web installer on port 4567
    2022-06-01T07:14:54.965Z [137319] - info: Web installer listening on http://0.0.0.0:4567
    2022-06-01T07:15:16.757Z [137319] - info: Starting setup process
    2022-06-01T07:15:19.081Z [137495] - info: NodeBB Setup Triggered via Command Line
    
    Welcome to NodeBB v2.0.0!
    
    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).
    2022-06-01T07:15:19.095Z [137495] - info: [install/checkSetupFlagEnv] checking env vars for setup info...
    2022-06-01T07:15:19.451Z [137495] - info: 
    Now configuring mongo database:
    2022-06-01T07:15:20.181Z [137495] - warn: NodeBB Setup Aborted.
     MongoServerError: Authentication failed.
        at Connection.onMessage (/home/napishtim/nodebb/node_modules/mongodb/lib/cmap/connection.js:203:30)
        at MessageStream.<anonymous> (/home/napishtim/nodebb/node_modules/mongodb/lib/cmap/connection.js:63:60)
        at MessageStream.emit (node:events:527:28)
        at processIncomingData (/home/napishtim/nodebb/node_modules/mongodb/lib/cmap/message_stream.js:108:16)
        at MessageStream._write (/home/napishtim/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:527:28)
    
    ![error.jpg](/assets/uploads/files/1654069855850-error.jpg) 
    
    It is something wrong with MongoDB. How can I install nodebb?
  • @napishtim Did you complete steps in terms of setting up and securing MongoDB as per the documentation ?

  • This post is deleted!
  • @phenomlab said in MongoServerError: Authentication failed.:

    Did you complete steps in terms of setting up and securing MongoDB as per the documentation ?

    You mean I need type:

    sudo vim /etc/mongod.conf
    

    Then

    # mongod.conf
    
    # for documentation of all options, see:
    #   http://docs.mongodb.org/manual/reference/configuration-options/
    
    # Where and how to store data.
    storage:
      dbPath: /var/lib/mongodb
      journal:
        enabled: true
    #  engine:
    #  wiredTiger:
    
    # where to write logging data.
    systemLog:
      destination: file
      logAppend: true
      path: /var/log/mongodb/mongod.log
    
    # network interfaces
    net:
      port: 27017
      bindIp: 127.0.0.1
    
    
    # how the process runs
    processManagement:
      timeZoneInfo: /usr/share/zoneinfo
    
    #security:
      authorization: enabled
    #operationProfiling:
    
    #replication:
    
    #sharding:
    
    ## Enterprise-Only Options:
    
    #auditLog:
    
    #snmp:
    

    Is these right?

  • @napishtim yes. Did you restart MongoDB after making those changes?

  • @phenomlab

    mongo -u admin -p myadminpassoword --authenticationDatabase=admin
    MongoDB shell version v5.0.8
    connecting to: mongodb://127.0.0.1:27017/?authSource=admin&compressors=disabled&gssapiServiceName=mongodb
    Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
    [email protected]/mongo/shell/mongo.js:372:17
    @(connect):2:6
    exception: connect failed
    exiting with code 1
    
    [email protected]:~/nodebb$ ./nodebb start
    2022-06-04T08:29:59.510Z [74573] - info: Launching web installer on port 4567
    2022-06-04T08:30:24.079Z [74573] - info: Web installer listening on http://0.0.0.0:4567
    2022-06-04T08:31:01.964Z [74573] - info: Starting setup process
    2022-06-04T08:31:04.300Z [74701] - info: NodeBB Setup Triggered via Command Line
    
    Welcome to NodeBB v2.0.0!
    
    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).
    2022-06-04T08:31:04.322Z [74701] - info: [install/checkSetupFlagEnv] checking env vars for setup info...
    2022-06-04T08:31:04.660Z [74701] - info: 
    Now configuring mongo database:
    2022-06-04T08:31:35.307Z [74701] - warn: NodeBB Setup Aborted.
     MongoServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
        at Timeout._onTimeout (/home/napishtim/nodebb/node_modules/mongodb/lib/sdam/topology.js:318:38)
        at listOnTimeout (node:internal/timers:559:17)
        at processTimers (node:internal/timers:502:7)
    

    It causes Connection refused. How can I do for these?

  • Have you checked if mongo is running?

    sudo systemctl status mongod
    
  • @PitaJ said in MongoServerError: Authentication failed.:

    sudo systemctl status mongod

    [email protected]:~$ sudo systemctl status mongod
    [sudo] napishtim 的密码: 
    ● mongod.service - MongoDB Database Server
         Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
         Active: active (running) since Sat 2022-06-04 16:59:21 CST; 20h ago
           Docs: https://docs.mongodb.org/manual
       Main PID: 76231 (mongod)
         Memory: 150.1M
         CGroup: /system.slice/mongod.service
                 └─76231 /usr/bin/mongod --config /etc/mongod.conf
    
    6月 04 16:59:21 napishtim-M14xR1 systemd[1]: Started MongoDB Database Server.
    

    I had repaired securing MongoDB. But I can not verify the administrative user created earlier can connect

    [email protected]:~$ mongo -u admin -p (myadminpassword) --authenticationDatabase=admin
    MongoDB shell version v5.0.8
    connecting to: mongodb://127.0.0.1:27017/?authSource=admin&compressors=disabled&gssapiServiceName=mongodb
    Error: Authentication failed. :
    [email protected]/mongo/shell/mongo.js:372:17
    @(connect):2:6
    exception: connect failed
    exiting with code 1
    
    
    
  • @napishtim did you create the administrator account under the admin database or nodebb ? If under nodebb but not admin, then this won't work.

  • @phenomlab
    Of course I had created it.

  • @napishtim Ok - have you tried the password you believe you set in uppercase, or with variations ?

  • @phenomlab My password consists of upper case letters, numbers and lower case letters.


Suggested Topics