🪴 notes

Search

Search IconIcon to open search

mongodb unauthorized error

Published Jun 2, 2023 Last updated Jun 2, 2023 Edit Source

1
MongoError: (Unauthorized) not authorized on admin  to execute command

If this error comes up when working with MongoDB, it could be that there are multiple databases in the mongodb instance. The db name should be specified in the connection string like:

1
mongodb+srv://<username>:<password>@test-auth.3w13ht5.mongodb.net/<dbname>?retryWrites=true&w=majority