MongoDB error during connection. I'm getting "MongoSecurityException: Exception authenticating"

I’m getting errors when trying to connect to MongoDB cluster. Locally it works fine. I’m using

mongo-java-driver => 3.12.10
org.mongodb.morphia → 1.3.2
MongoDB shell version v4.2.17

The error I’m getting is

Caused by: com.mongodb.MongoCommandException: Command failed with error 2 (BadValue): ‘Auth mechanism not specified’ on server mongo-a:27017.