title: Exception authenticating MongoCredential and Uncategorized Mongo Db Exception
body: <p><strong>I am getting this error socket exception raised by this connection while running my application.</strong></p>
  
  <pre><code>INFO 5231 --- [nio-8087-exec-1] org.mongodb.driver.connection: Closed connection [connectionId{localValue:2}] to 192.168.0.2:27017 because there was a socket exception raised by this connection.**
  
      org.springframework.data.mongodb.UncategorizedMongoDbException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='admin', source='campbell', password=&lt;hidden&gt;, mechanismProperties={}}; nested exception is com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='admin', source='campbell', password=&lt;hidden&gt;, mechanismProperties={}}
          at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:138)
          at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2756)
          at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:2666)
          at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:2409)
          at org.springframework.data.mongodb.core.ExecutableFindOperationSupport$ExecutableFindSupport.doFind(ExecutableFindOperationSupport.java:214)
  
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
          at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
          at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
          at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:791)
          at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1417)
          at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
          at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  
      Caused by: com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='admin', source='campbell', password=&lt;hidden&gt;, mechanismProperties={}}
  
      Caused by: com.mongodb.MongoCommandException: Command failed with error 18 (AuthenticationFailed): 'Authentication failed.' on server 192.168.0.2:27017. The full response is { "ok" : 0.0, "errmsg" : "Authentication failed.", "code" : 18, "codeName" : "AuthenticationFailed" }
  
  **I have declared properties in application properties-**
  spring.data.mongodb.database=dbname
  spring.data.mongodb.username=admin
  spring.data.mongodb.password=*******
  spring.data.mongodb.port=27017
  spring.data.mongodb.host=192.168.0.2
  </code></pre>
  
  <p>Login credentials are right still I am getting this error.
  Exception authenticating MongoCredential also I am getting  Uncategorized Mongo Db Exception    </p>
  
  <p>Please help me out!</p>