Docs Menu
Docs Home
MongoDB Manual
/ / /


On this page

  • Definition
  • Compatibility
  • Syntax
  • Command Fields
  • Access Control
  • Behavior
  • Example

The dropConnections command drops the mongod / mongos instance's outgoing connections to the specified hosts. The dropConnections must be run against the admin database.

This command is available in deployments hosted in the following environments:

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud


This command is supported in all MongoDB Atlas clusters. For information on all commands, see Unsupported Commands.

The command has following syntax:

dropConnections: 1,
hostAndPort : [ "host1:port1", "host2:port2", ... ],
comment: <any>

The command requires the following field:

Each array element represents the hostname and port of a remote machine.

Optional. A user-provided comment to attach to this command. Once set, this comment appears alongside records of this command in the following locations:

A comment can be any valid BSON type (string, integer, object, array, etc).

If the deployment enforces authentication/authorization, the dropConnections command requires the dropConnections action on the cluster resource.

Create a user-defined role in the admin database where the privilege array includes the following document:

{ "resource" : { "cluster" : true } }, "actions" : [ "dropConnections" ] }

For example, the following operation creates a user-defined role on the admin database with the privileges to support dropConnections:

"role" : "dropConnectionsRole",
"privileges" : [
"resource" : { "cluster" : true },
"actions" : [ "dropConnections" ]
"roles" : []

Assign the custom role to a user on the admin database:

"user" : "dropConnectionsUser",
"pwd" : "replaceThisWithASecurePassword",
"roles" : [ "dropConnectionsRole" ]

The created user can execute dropConnections.

For more examples of user creation, see Create a User. For a tutorial on adding privileges to an existing database user, see Modify Access for an Existing User.

dropConnections silently ignores hostAndPort elements that do not include both the hostname and port of the remote machine.

Consider a replica set with a recently removed member at Running the following dropConnections command against each active replica set member ensures there are no remaining outgoing connections to

"dropConnections" : 1,
"hostAndPort" : [

The command returns output similar to the following:

"ok" : 1,
"$clusterTime" : {
"clusterTime" : Timestamp(1551375968, 1),
"signature" : {
"keyId" : NumberLong(0)
"operationTime" : Timestamp(1551375968, 1)

You can confirm the status of the connection pool for the mongod or mongos using the connPoolStats command.

← dropDatabase