Mongo::Auth::Unauthorized: User production_user (mechanism: scram) is not authorized to access *_production

Has anyone encountered the following error with a Rails application using Mongoid 7.5?

[Mongo::Auth::Unauthorized: User production_user ``(mechanism: scram) is not authorized to access xxx_production]
used mechanism: SCRAM-SHA-1, used server: yyy.gdren.mongodb.net:27016 (MONGOS)): [18:AuthenticationFailed]: Authentication failed. (modern retry, attempt 1)
```

Any advice on how to resolve this?

Hey @Dat_Ta,

[Mongo::Auth::Unauthorized: User production_user ``(mechanism: scram) is not authorized to access xxx_production] used mechanism: SCRAM-SHA-1, used server: yyy.gdren.mongodb.net:27016 (MONGOS)): [18:AuthenticationFailed]: Authentication failed. (modern retry, attempt 1)

The error you’re seeing is coming from the server and indicates the production_user can not access the xxx_production database. If cluster authentication or authorization rules changed, the Mongoid process would need to be restarted with these update credential (likely updated in the mongoid.yml).