"MongoError: not authorized on [dbName] to execute command" in Production

1,016 views
Skip to first unread message

Francesco Rivola

unread,
Aug 31, 2018, 4:30:19 AM8/31/18
to mongodb-user
Hi all,

I am writing to ask a question regarding an issue we ran into today in production:

We started to experience the following error:
  • MongoError: not authorized on [dbName] to execute command { insert: \"[collectionName]\", documents: ...
The error seems affecting all type of commands (update, insert, count, etc..)

After restart our application the issue gone. And the entire system come back to a safe state.

Env info:
  • Application is a nodejs app using mongodb nodejs driver 3.1.3 (we are NOT using mongoose)
  • Mongo Server is running on a linux Ubutu 18.04.1 LTS
  • Mongo Server version is 3.4.15
Anybody know the possible cause of this issue?

Thank you in advanced.

Best Regards,
Francesco Rivola

Wan Bachtiar

unread,
Sep 11, 2018, 3:23:16 AM9/11/18
to mongodb-user

MongoError: not authorized on [dbName] to execute command { insert: \”[collectionName]\”, documents: …

Hi Francesco,

The error message indicates that the application user does not have the right permission to perform the operation. It is likely that either the application is not authenticating against the right database, or perhaps the users role has changed momentarily. 

Make sure that the right user/password combination to authenticate with has the level of access the application requires and that the details in your connection string/options match those on the server. Also, check whether there has been any changes in regards to the user’s permission/roles.

Regards,
Wan.

Francesco Rivola

unread,
Sep 11, 2018, 12:24:27 PM9/11/18
to mongodb-user
Hi Wan,

Thank you very much for your response.

That's the weird thing, as far as I know the database and the user/role hasn't change. To fix the issue we just restarted the application with no changes to the database.

I thought it was maybe some transient issue of the connection between the database and the app and that the reported error maybe was hiding the real problem.

Luckly we haven't experienced again this issue.

Thank you so much.

Best Regards,
Francesco Rivola

Reply all
Reply to author
Forward
0 new messages