How to resolve: MongoDB.Driver.MongoAuthenticationException: Unable to authenticate using sasl protocol mechanism SCRAM-SHA-1.

I came across this error today whilst trying to deploy my application on Azure.

MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server. ---> MongoDB.Driver.MongoAuthenticationException: Unable to authenticate using sasl protocol mechanism SCRAM-SHA-1.

As it turns out, MongoDB may have separate databases for authentication and data and therefore it is essential to specify which database to authenticate against. My initial settings were:

It happens that for mlabs' databases the authentication occurs in the database you created (unless you are on the premium). Therefore the connection string should look like this:

1 thought on “How to resolve: MongoDB.Driver.MongoAuthenticationException: Unable to authenticate using sasl protocol mechanism SCRAM-SHA-1.”

Leave a comment