MongoError: not authorized for query on ***
See original GitHub issueHi,
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:
- Created 7 years ago
- Comments:10 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey,
We are still encountering this issue
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?
@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