UnhandledPromiseRejectionWarning: MongoError: not authorized on test to execute command...What the smoke?

Bruce Gust
Bruce Gust used Ask the Experts™
We've been asked to download a project and be ready to comment intelligently in a meeting tomorrow, so I'm trying to get this app up and running on my local box, but I'm running into errors that I've not encountered before.

Here is the error as it appears on my terminal:

Listening on PORT: 3000
(node:3316) UnhandledPromiseRejectionWarning: MongoError: not authorized on test to execute command { insert: "system.indexes", documents: [ { ns: "test.user_sess
ions", key: { expires: 1 }, name: "expires_1", expireAfterSeconds: 0, unique: false } ], ordered: true, writeConcern: { w: "majority" }, lsid: { id: UUID("9674b2b
b-4da6-401a-9d90-7b0f35ace911") }, readConcern: { afterClusterTime: Timestamp(1579010568, 1) }, $clusterTime: { clusterTime: Timestamp(1579010568, 1), signature:
{ hash: BinData(0, 2F281F7B9881E802501648F77CC4113E4B119167), keyId: 6749132984986632193 } }, $db: "test" }
    at Connection.<anonymous> (C:\wamp64\www\bsmart\PRAMS\node_modules\mongoose\node_modules\mongodb-core\lib\connection\pool.js:443:61)
    at Connection.emit (events.js:210:5)
    at processMessage (C:\wamp64\www\bsmart\PRAMS\node_modules\mongoose\node_modules\mongodb-core\lib\connection\connection.js:364:10)
    at TLSSocket.<anonymous> (C:\wamp64\www\bsmart\PRAMS\node_modules\mongoose\node_modules\mongodb-core\lib\connection\connection.js:533:15)
    at TLSSocket.emit (events.js:210:5)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:290:11)
    at TLSSocket.Readable.push (_stream_readable.js:224:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:182:23)
(node:3316) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch bl
ock, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:3316) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the N
ode.js process with a non-zero exit code.

Open in new window


Here's the error as it appears on my web browser:

Error: secret option required for sessions
    at session (C:\wamp64\www\bsmart\PRAMS\node_modules\express-session\index.js:200:12)
    at Layer.handle [as handle_request] (C:\wamp64\www\bsmart\PRAMS\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (C:\wamp64\www\bsmart\PRAMS\node_modules\express\lib\router\index.js:317:13)
    at C:\wamp64\www\bsmart\PRAMS\node_modules\express\lib\router\index.js:284:7
    at Function.process_params (C:\wamp64\www\bsmart\PRAMS\node_modules\express\lib\router\index.js:335:12)
    at next (C:\wamp64\www\bsmart\PRAMS\node_modules\express\lib\router\index.js:275:10)
    at expressInit (C:\wamp64\www\bsmart\PRAMS\node_modules\express\lib\middleware\init.js:40:5)
    at Layer.handle [as handle_request] (C:\wamp64\www\bsmart\PRAMS\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (C:\wamp64\www\bsmart\PRAMS\node_modules\express\lib\router\index.js:317:13)
    at C:\wamp64\www\bsmart\PRAMS\node_modules\express\lib\router\index.js:284:7
    at Function.process_params (C:\wamp64\www\bsmart\PRAMS\node_modules\express\lib\router\index.js:335:12)
    at next (C:\wamp64\www\bsmart\PRAMS\node_modules\express\lib\router\index.js:275:10)
    at query (C:\wamp64\www\bsmart\PRAMS\node_modules\express\lib\middleware\query.js:45:5)
    at Layer.handle [as handle_request] (C:\wamp64\www\bsmart\PRAMS\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (C:\wamp64\www\bsmart\PRAMS\node_modules\express\lib\router\index.js:317:13)
    at C:\wamp64\www\bsmart\PRAMS\node_modules\express\lib\router\index.js:284:7
    at Function.process_params (C:\wamp64\www\bsmart\PRAMS\node_modules\express\lib\router\index.js:335:12)
    at next (C:\wamp64\www\bsmart\PRAMS\node_modules\express\lib\router\index.js:275:10)
    at Function.handle (C:\wamp64\www\bsmart\PRAMS\node_modules\express\lib\router\index.js:174:3)
    at Function.handle (C:\wamp64\www\bsmart\PRAMS\node_modules\express\lib\application.js:174:10)
    at Server.app (C:\wamp64\www\bsmart\PRAMS\node_modules\express\lib\express.js:39:9)
    at Server.<anonymous> (C:\wamp64\www\bsmart\PRAMS\node_modules\engine.io\lib\server.js:470:22)

Open in new window


What does all of this mean and how can I fix it?

Thanks!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2017
Distinguished Expert 2018
The key bit is here
UnhandledPromiseRejectionWarning: MongoError: not authorized on test to execute command { insert: "system.indexes", documents: [ { ns: "test.user_sess
ions", key: { expires: 1 }, name: "expires_1", expireAfterSeconds: 0, unique: false } ], ordered: true, writeConcern: { w: "majority" }, lsid: { id: UUID("9674b2b
b-4da6-401a-9d90-7b0f35ace911") }, readConcern: { afterClusterTime: Timestamp(1579010568, 1) }, $clusterTime: { clusterTime: Timestamp(1579010568, 1), signature:
{ hash: BinData(0, 2F281F7B9881E802501648F77CC4113E4B119167), keyId: 6749132984986632193 } }, $db: "test" }

Open in new window

The process in question does not have the rights to insert to system.indexes on the MongoDb [test].

Looks like a permissions problem.
Bruce GustPHP Developer

Author

Commented:
That makes sense!

Thanks, Julian!
Most Valuable Expert 2017
Distinguished Expert 2018
You are welcome.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial