com.mongodb.MongoCommandException: Command failed with error 13: 'not authorized on myapp to execute command { aggregate: "todo", pipeline: [ { $project: { _id: 1 } }, { $group: { _id: 0, count: { $sum: 1 } } } ], cursor: { batchSize: 128 } }' on server localhost:27017. The full response is { "ok" : 0.0, "errmsg" : "not authorized on myapp to execute command { aggregate: \"todo\", pipeline: [ { $project: { _id: 1 } }, { $group: { _id: 0, count: { $sum: 1 } } } ], cursor: { batchSize: 128 } }", "code" : 13 }

Searched on Google with the first line of a JAVA stack trace?

We can recommend more relevant solutions and speed up debugging when you paste your entire stack trace with the exception message. Try a sample exception.

Recommended solutions based on your search

Samebug tips

Do you know how to solve this issue? Write a tip to help other users and build your expert profile.

Solutions on the web

via GitHub by xmlking
, 1 year ago
Command failed with error 13: 'not authorized on myapp to execute command { aggregate: "todo", pipeline: [ { $project: { _id: 1 } }, { $group: { _id: 0, count: { $sum: 1 } } } ], cursor: { batchSize: 128 } }' on server localhost:27017. The full
via JIRA by Jeff Yemin, 1 year ago
Command failed with error 13140: 'exception: Don't recognize source or target DB' on server localhost:27018. The full response is { "code" : 13140, "ok" : 0.0, "errmsg" : "exception: Don't recognize source or target DB" }
via JIRA by Jeff Yemin, 1 year ago
Command failed with error 13140: 'exception: Don't recognize source or target DB' on server localhost:27018. The full response is { "code" : 13140, "ok" : 0.0, "errmsg" : "exception: Don't recognize source or target DB" }
via GitHub by ngtandat
, 1 year ago
" : 0.0 }: Command failed with error 15981: 'exception: the $unwind field path must be specified as a string' on server localhost:27017. The full response is { "errmsg" : "exception: the $unwind field path must be specified as a string", "code" : 15981, "ok" : 0.0 }
via GitHub by gbrd
, 2 months ago
Command failed with error 16028: 'exception: collection or index disappeared when cursor yielded' on server 127.0.0.1:27017. The full response is { "errmsg" : "exception: collection or index disappeared when cursor yielded", "code" : 16028, "ok" : 0.0 }
via Google Groups by Unknown author, 4 months ago
Command failed with error 2: 'unknown top level operator: $match' on server localhost:27017. The full response is { "ok" : 0.0, "errmsg" : "unknown top level operator: $match", "code" : 2, "codeName" : "BadValue" }
com.mongodb.MongoCommandException: Command failed with error 13: 'not authorized on myapp to execute command { aggregate: "todo", pipeline: [ { $project: { _id: 1 } }, { $group: { _id: 0, count: { $sum: 1 } } } ], cursor: { batchSize: 128 } }' on server localhost:27017. The full response is { "ok" : 0.0, "errmsg" : "not authorized on myapp to execute command { aggregate: \"todo\", pipeline: [ { $project: { _id: 1 } }, { $group: { _id: 0, count: { $sum: 1 } } } ], cursor: { batchSize: 128 } }", "code" : 13 }
at com.mongodb.connection.ProtocolHelper.getCommandFailureException(ProtocolHelper.java:86)
at com.mongodb.connection.CommandResultCallback.callCallback(CommandResultCallback.java:51)
at com.mongodb.connection.CommandResultCallback.callCallback(CommandResultCallback.java:29)
at com.mongodb.connection.CommandResultBaseCallback.callCallback(CommandResultBaseCallback.java:39)
at com.mongodb.connection.ResponseCallback.onResult(ResponseCallback.java:48)
at com.mongodb.connection.ResponseCallback.onResult(ResponseCallback.java:23)
at com.mongodb.connection.DefaultConnectionPool$PooledConnection$2.onResult(DefaultConnectionPool.java:463)
at com.mongodb.connection.DefaultConnectionPool$PooledConnection$2.onResult(DefaultConnectionPool.java:457)
at com.mongodb.connection.UsageTrackingInternalConnection$3.onResult(UsageTrackingInternalConnection.java:127)
at com.mongodb.connection.UsageTrackingInternalConnection$3.onResult(UsageTrackingInternalConnection.java:123)
at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53)
at com.mongodb.connection.InternalStreamConnection.executeCallbackAndReceiveResponse(InternalStreamConnection.java:375)
at com.mongodb.connection.InternalStreamConnection.access$1700(InternalStreamConnection.java:65)
at com.mongodb.connection.InternalStreamConnection$ResponseBuffersCallback.onResult(InternalStreamConnection.java:417)
at com.mongodb.connection.InternalStreamConnection$ResponseBuffersCallback.onResult(InternalStreamConnection.java:386)
at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback.onSuccess(InternalStreamConnection.java:555)
at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback.access$2200(InternalStreamConnection.java:514)
at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback$ResponseBodyCallback.onResult(InternalStreamConnection.java:577)
at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback$ResponseBodyCallback.onResult(InternalStreamConnection.java:561)
at com.mongodb.connection.InternalStreamConnection$3.completed(InternalStreamConnection.java:444)
at com.mongodb.connection.InternalStreamConnection$3.completed(InternalStreamConnection.java:441)
at com.mongodb.connection.AsynchronousSocketChannelStream$BasicCompletionHandler.completed(AsynchronousSocketChannelStream.java:218)
at com.mongodb.connection.AsynchronousSocketChannelStream$BasicCompletionHandler.completed(AsynchronousSocketChannelStream.java:201)
at com.mongodb.connection.AsynchronousSocketChannelStream.readAsync(AsynchronousSocketChannelStream.java:125)
at com.mongodb.connection.InternalStreamConnection.readAsync(InternalStreamConnection.java:441)
at com.mongodb.connection.InternalStreamConnection.access$2000(InternalStreamConnection.java:65)
at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback.onResult(InternalStreamConnection.java:537)
at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback.onResult(InternalStreamConnection.java:514)
at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53)
at com.mongodb.connection.InternalStreamConnection$3.completed(InternalStreamConnection.java:444)
at com.mongodb.connection.InternalStreamConnection$3.completed(InternalStreamConnection.java:441)
at com.mongodb.connection.AsynchronousSocketChannelStream$BasicCompletionHandler.completed(AsynchronousSocketChannelStream.java:218)
at com.mongodb.connection.AsynchronousSocketChannelStream$BasicCompletionHandler.completed(AsynchronousSocketChannelStream.java:201)
at com.mongodb.connection.AsynchronousSocketChannelStream.readAsync(AsynchronousSocketChannelStream.java:125)
at com.mongodb.connection.InternalStreamConnection.readAsync(InternalStreamConnection.java:441)
at com.mongodb.connection.InternalStreamConnection.receiveResponseAsync(InternalStreamConnection.java:430)
at com.mongodb.connection.InternalStreamConnection.executeCallbackAndReceiveResponse(InternalStreamConnection.java:382)
at com.mongodb.connection.InternalStreamConnection.receiveMessageAsync(InternalStreamConnection.java:366)
at com.mongodb.connection.UsageTrackingInternalConnection.receiveMessageAsync(UsageTrackingInternalConnection.java:130)
at com.mongodb.connection.DefaultConnectionPool$PooledConnection.receiveMessageAsync(DefaultConnectionPool.java:457)
at com.mongodb.connection.SendMessageCallback.onResult(SendMessageCallback.java:45)
at com.mongodb.connection.SendMessageCallback.onResult(SendMessageCallback.java:22)
at com.mongodb.connection.DefaultConnectionPool$PooledConnection$1.onResult(DefaultConnectionPool.java:449)
at com.mongodb.connection.DefaultConnectionPool$PooledConnection$1.onResult(DefaultConnectionPool.java:443)
at com.mongodb.connection.UsageTrackingInternalConnection$2.onResult(UsageTrackingInternalConnection.java:114)
at com.mongodb.connection.UsageTrackingInternalConnection$2.onResult(UsageTrackingInternalConnection.java:110)
at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53)
at com.mongodb.connection.InternalStreamConnection$2.completed(InternalStreamConnection.java:309)
at com.mongodb.connection.InternalStreamConnection$2.completed(InternalStreamConnection.java:294)
at com.mongodb.connection.AsynchronousSocketChannelStream$1.completed(AsynchronousSocketChannelStream.java:111)
at com.mongodb.connection.AsynchronousSocketChannelStream$1.completed(AsynchronousSocketChannelStream.java:105)
at com.mongodb.connection.AsynchronousSocketChannelStream$2.completed(AsynchronousSocketChannelStream.java:164)
at com.mongodb.connection.AsynchronousSocketChannelStream$2.completed(AsynchronousSocketChannelStream.java:158)
at com.mongodb.connection.AsynchronousSocketChannelStream$AsyncWritableByteChannelAdapter$WriteCompletionHandler.completed(AsynchronousSocketChannelStream.java:190)
at java.nio.channels.AsynchronousSocketChannel.write(AsynchronousSocketChannel.java:577)
at com.mongodb.connection.AsynchronousSocketChannelStream$AsyncWritableByteChannelAdapter.write(AsynchronousSocketChannelStream.java:178)
at com.mongodb.connection.AsynchronousSocketChannelStream.pipeOneBuffer(AsynchronousSocketChannelStream.java:158)
at com.mongodb.connection.AsynchronousSocketChannelStream.writeAsync(AsynchronousSocketChannelStream.java:105)
at com.mongodb.connection.InternalStreamConnection.writeAsync(InternalStreamConnection.java:294)
at com.mongodb.connection.InternalStreamConnection.sendMessageAsync(InternalStreamConnection.java:288)
at com.mongodb.connection.UsageTrackingInternalConnection.sendMessageAsync(UsageTrackingInternalConnection.java:117)
at com.mongodb.connection.DefaultConnectionPool$PooledConnection.sendMessageAsync(DefaultConnectionPool.java:443)
at com.mongodb.connection.CommandProtocol.executeAsync(CommandProtocol.java:162)
at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.executeAsync(DefaultServer.java:169)
at com.mongodb.connection.DefaultServerConnection.executeProtocolAsync(DefaultServerConnection.java:292)
at com.mongodb.connection.DefaultServerConnection.commandAsync(DefaultServerConnection.java:181)
at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocolAsync(CommandOperationHelper.java:368)
at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocolAsync(CommandOperationHelper.java:358)
at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocolAsync(CommandOperationHelper.java:263)
at com.mongodb.operation.AggregateOperation$2$1.call(AggregateOperation.java:250)
at com.mongodb.operation.OperationHelper.checkValidReadConcern(OperationHelper.java:90)
at com.mongodb.operation.AggregateOperation$2.call(AggregateOperation.java:244)
at com.mongodb.operation.OperationHelper$2.onResult(OperationHelper.java:290)
at com.mongodb.operation.OperationHelper$2.onResult(OperationHelper.java:287)
at com.mongodb.connection.DefaultServer$1.onResult(DefaultServer.java:91)
at com.mongodb.connection.DefaultServer$1.onResult(DefaultServer.java:82)
at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53)
at com.mongodb.connection.DefaultConnectionPool$2.onResult(DefaultConnectionPool.java:201)
at com.mongodb.connection.DefaultConnectionPool$2.onResult(DefaultConnectionPool.java:186)
at com.mongodb.connection.UsageTrackingInternalConnection$1.onResult(UsageTrackingInternalConnection.java:62)
at com.mongodb.connection.UsageTrackingInternalConnection$1.onResult(UsageTrackingInternalConnection.java:54)
at com.mongodb.connection.InternalStreamConnection$1$1.onResult(InternalStreamConnection.java:155)
at com.mongodb.connection.InternalStreamConnection$1$1.onResult(InternalStreamConnection.java:142)
at com.mongodb.connection.InternalStreamConnectionInitializer$3.onResult(InternalStreamConnectionInitializer.java:146)
at com.mongodb.connection.InternalStreamConnectionInitializer$3.onResult(InternalStreamConnectionInitializer.java:140)
at com.mongodb.connection.CommandHelper$1$1.onResult(CommandHelper.java:53)
at com.mongodb.connection.CommandHelper$1$1.onResult(CommandHelper.java:43)
at com.mongodb.connection.CommandHelper$3.onResult(CommandHelper.java:155)
at com.mongodb.connection.CommandHelper$3.onResult(CommandHelper.java:148)
at com.mongodb.connection.InternalStreamConnection.executeCallbackAndReceiveResponse(InternalStreamConnection.java:375)
at com.mongodb.connection.InternalStreamConnection.access$1700(InternalStreamConnection.java:65)
at com.mongodb.connection.InternalStreamConnection$ResponseBuffersCallback.onResult(InternalStreamConnection.java:417)
at com.mongodb.connection.InternalStreamConnection$ResponseBuffersCallback.onResult(InternalStreamConnection.java:386)
at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback.onSuccess(InternalStreamConnection.java:555)
at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback.access$2200(InternalStreamConnection.java:514)
at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback$ResponseBodyCallback.onResult(InternalStreamConnection.java:577)
at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback$ResponseBodyCallback.onResult(InternalStreamConnection.java:561)
at com.mongodb.connection.InternalStreamConnection$3.completed(InternalStreamConnection.java:444)
at com.mongodb.connection.InternalStreamConnection$3.completed(InternalStreamConnection.java:441)
at com.mongodb.connection.AsynchronousSocketChannelStream$BasicCompletionHandler.completed(AsynchronousSocketChannelStream.java:218)
at com.mongodb.connection.AsynchronousSocketChannelStream$BasicCompletionHandler.completed(AsynchronousSocketChannelStream.java:201)
at com.mongodb.connection.AsynchronousSocketChannelStream.readAsync(AsynchronousSocketChannelStream.java:125)
at com.mongodb.connection.InternalStreamConnection.readAsync(InternalStreamConnection.java:441)
at com.mongodb.connection.InternalStreamConnection.access$2000(InternalStreamConnection.java:65)
at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback.onResult(InternalStreamConnection.java:537)
at com.mongodb.connection.InternalStreamConnection$ResponseHeaderCallback.onResult(InternalStreamConnection.java:514)
at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53)
at com.mongodb.connection.InternalStreamConnection$3.completed(InternalStreamConnection.java:444)
at com.mongodb.connection.InternalStreamConnection$3.completed(InternalStreamConnection.java:441)
at com.mongodb.connection.AsynchronousSocketChannelStream$BasicCompletionHandler.completed(AsynchronousSocketChannelStream.java:218)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Users with the same issue

195 times, 1 week ago
2 times, 4 weeks ago
4 times, 1 month ago
2 times, 6 months ago
Once, 8 months ago

Write tip

Know the solutions? Share your knowledge to help other developers to debug faster.