question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MongoError: not authorized for query on ***

See original GitHub issue

Hi,

The last week we have been getting a lot of errors about not being able to execute commands on our production replica set.

The error occurs on several collections, but the users collection is the most common one. The error output is like this:

MongoError: not authorized for query on addb.users
    at Function.MongoError.create (/home/backend/main/node_modules/mongoose/node_modules/mongodb-core/lib/error.js:31:11)
    at queryCallback (/home/backend/main/node_modules/mongoose/node_modules/mongodb-core/lib/cursor.js:182:34)
    at Callbacks.emit (/home/backend/main/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/server.js:119:3)
    at null.messageHandler (/home/backend/main/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/server.js:358:23)
    at Socket.<anonymous> (/home/backend/main/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js:292:22)
    at emitOne (events.js:90:13)
    at Socket.emit (events.js:182:7)
    at readableAddChunk (_stream_readable.js:153:18)
    at Socket.Readable.push (_stream_readable.js:111:10)
    at TCP.onread (net.js:534:20)

I believe this issue should have been solved as of 4.5.5, but it may have re-emerged. I’m not able to get rid of it, and it now happens for me with mongoose versions 4.4.14, 4.5.5, 4.5.8, and 4.5.9.

It could be noted that it usually only occur at one of the production servers at the time, and that the app are working, except for when these errors occur.

Are anyone else experiencing similar issues?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
unDemiancommented, Aug 30, 2016

Hey,

We are still encountering this issue

MongoError :: not authorized on databaseName to execute command { find: "collection"...

Stack
        "node_modules/mongodb-core/lib/error.js:31:11",
        "node_modules/mongodb-core/lib/cursor.js:200:36",
        "node_modules/mongodb-core/lib/topologies/server.js:119:3",
        "node_modules/mongodb-core/lib/topologies/server.js:358:23",
        "node_modules/mongodb-core/lib/connection/connection.js:292:22",
        "events.js:96:13",
        "events.js:188:7",
        "_stream_readable.js:172:18",
        "_stream_readable.js:130:10",
        "net.js:542:20"

mongoose version: 4.5.10 mongodb version (default with mongoose): 2.1.18 mongodb-core version (default with mongodb): 1.3.18

I checked these are the only packages installed.

It seems to be fixed in 2.2.0 https://jira.mongodb.org/browse/NODE-722?jql=project %3D NODE AND text ~ "not authorized" I guess I should wait for you guys to adopt the new mongodb version? Any plans or roadmap for that?

0reactions
ktkaushikcommented, Sep 29, 2016

@unDemian Thanks for the solution. We were having similar problems with 4.4.12 on our system. We have now moved to 4.5.10 and it all seems to work fine.

What’s funny is that i restarted my pm2 application and things just fell apart. I didn’t do a npm install or anything but it still did fell apart. I was getting error on querying to the entire database.

Here is my updated stack -

mongoose - 4.5.10 mongodb-core - 1.3.21 mongodb - 2.1.21

thanks @vkarpov15 @axelfran

Read more comments on GitHub >

github_iconTop Results From Across the Web

MongoDB not authorized for query - code 13 - Stack Overflow
MongoError : not authorized on mydb to execute command { count: "urls", query: {} }. This error was caused by a userid and...
Read more >
Not Authorized on <dbName> to execute Command - MongoDB
when I connect to the MongoDB cluster with the string provided in chapter zero and try to query the movies db, I am...
Read more >
Not authorized for query on - Questions / Help - Elixir Forum
I'm using a new version of mongodb lib in my project and when I try to execute a query (Mongo.find()) I get the...
Read more >
Not authorized on test to execute command
I have no clue why I am getting this error not authorized on test to execute command , and in the return string...
Read more >
article-cust - TIBCO Support
Sorry, you are not logged in. Your login session has expired. Please click on the link below to re-login to support.tibco.com ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found