Mongorestore ReplicaSet createIndex error: (Unauthorized) command createIndexes requires authentication

Hello.

I am trying to perform a backup and restore of a mongodb ReplicaSet.
During the restore I get error at the end of the command:

......
finished restoring test.dev-db (100 documents, 0 failures)
restoring users from archive '/tmp/backup.gz'
restoring indexes for collection test.hour from metadata
index: &idx.IndexDocument{Options:primitive.M{"name":"timestampAscending", "v":2}, Key:primitive.D{primitive.E{Key:"timestamp", Value:1}}, PartialFilterExpression:primitive.D(nil)}
restoring indexes for collection test.day from metadata
index: &idx.IndexDocument{Options:primitive.M{"name":"timestampAscending", "v":2}, Key:primitive.D{primitive.E{Key:"timestamp", Value:1}}, PartialFilterExpression:primitive.D(nil)}
index: &idx.IndexDocument{Options:primitive.M{"name":"companyAscending", "v":2}, Key:primitive.D{primitive.E{Key:"company", Value:1}}, PartialFilterExpression:primitive.D(nil)}
index: &idx.IndexDocument{Options:primitive.M{"name":"companyAscending", "v":2}, Key:primitive.D{primitive.E{Key:"company", Value:1}}, PartialFilterExpression:primitive.D(nil)}
restoring indexes for collection test.week from metadata
index: &idx.IndexDocument{Options:primitive.M{"name":"timestampAscending", "v":2}, Key:primitive.D{primitive.E{Key:"timestamp", Value:1}}, PartialFilterExpression:primitive.D(nil)}
index: &idx.IndexDocument{Options:primitive.M{"name":"companyAscending", "v":2}, Key:primitive.D{primitive.E{Key:"company", Value:1}}, PartialFilterExpression:primitive.D(nil)}
Failed: test.day: error creating indexes for test.day: createIndex error: (Unauthorized) command createIndexes requires authentication
200 document(s) restored successfully. 0 document(s) failed to restore.

The command I am using is:

mongorestore --uri="mongodb://mongodb-0.mongodb-svc.mongodb.svc.cluster.local:27017,mongodb-1.mongodb-svc.mongodb.svc.cluster.local:27017,mongodb-2.mongodb-svc.mongodb.svc.cluster.local:27017" --username=restore-user --password 'password' --drop --archive="backup-mongodb.gz" --gzip

I tried using the user who has restore rights and also root. but the result is the same.

The version of mongoDB server used is 4.4.13, and the version of mongodump and mongorestore is 100.5.2.

Thanks

Try with authenticationDatabase parameter

yes, thank you! I added also --oplogReplay, it works well! thanks a lot