diff --git a/lib/storage/mongo-storage.js b/lib/storage/mongo-storage.js index 987e41ef67d..261e10ee3bd 100644 --- a/lib/storage/mongo-storage.js +++ b/lib/storage/mongo-storage.js @@ -42,7 +42,7 @@ function init(env, cb, forceNewConnection) { const result = await mongo.db.command({ connectionStatus: 1 }); const roles = result.authInfo.authenticatedUserRoles; - if (roles.length > 0 && roles[0].role == 'readAnyDatabase') { + if (roles && roles.length > 0 && roles[0].role == 'readAnyDatabase') { console.error('Mongo user is read only'); cb(new Error('MongoDB connection is in read only mode! Go back to MongoDB configuration and check your database user has read and write access.'), null); }