I followed the Mlab migration guide to migrate a Mlab Sandbox database to an Atlas. When I use the provided connection string in my application, I am unable to write to the database. I can only read from it.
I do something like below
const toSave = new Model({key: value});
toSave.save()
Error
{
"message": {
"operationTime": "6890830329813139457",
"ok": 0,
"code": 13,
"codeName": "Unauthorized",
"$clusterTime": {
"clusterTime": "6890830329813139457",
},
"name": "MongoError"
}
}
Additional Info
I can read from the database
I can read and write to the database from the terminal, I can’t write with my application
Ubuntu 16 LTS
Network access is at allow all 0.0.0.0/0 (includes your current IP address)
User access: readWriteAnyDatabase@admin
Mongoose version: v5.10
MongoDB server version v4.2
Type: Replica set
Cluster Tier: M0 Sandbox (General)
Connection string: mongodb+srv://username:password@staging.7gekl.mongodb.net/dbname?retryWrites=true&w=majority