> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

# stopShardDraining (database command)

## Definition

Stops the balancer from draining chunks off the given shard.

When the command runs, it tells the balancer that you want the shard to remain in the cluster. The balancer then stops draining the shard and again includes the shard in rebalance operations, shifting chunks back onto the shard.

The command returns an error if the shard doesn't exist, otherwise it returns `ok`.

To start draining a shard, use the [`startShardDraining`](https://www.mongodb.com/docs/manual/reference/command/startsharddraining.md#mongodb-dbcommand-dbcmd.startShardDraining) command.

To check the status of a draining shard, use the [`shardDrainingStatus`](https://www.mongodb.com/docs/manual/reference/command/sharddrainingstatus.md#mongodb-dbcommand-dbcmd.shardDrainingStatus) command.

To remove a shard after it finishes draining, use the [`commitShardRemoval`](https://www.mongodb.com/docs/manual/reference/command/commitshardremoval.md#mongodb-dbcommand-dbcmd.commitShardRemoval) command.

**New in version 8.3**

## Compatibility

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

- [MongoDB Enterprise](https://www.mongodb.com/docs/manual/administration/install-enterprise.md#std-label-install-mdb-enterprise): The subscription-based, self-managed version of MongoDB

- [MongoDB Community](https://www.mongodb.com/docs/manual/administration/install-community.md#std-label-install-mdb-community-edition): The source-available, free-to-use, and self-managed version of MongoDB

**Note:**

This command is not supported in [MongoDB Atlas](https://www.mongodb.com/docs/atlas). See [Modify your Atlas Sharded Cluster](https://www.mongodb.com/docs/atlas/scale-cluster/#modify-the-number-of-shards) to add or remove shards from your Atlas cluster.

## Syntax

The command has the following syntax:

```javascript
db.adminCommand( {
     stopShardDraining: <shard>
} )
```

## Behavior

### Access Requirements

If you have [`authorization`](https://www.mongodb.com/docs/manual/reference/configuration-options.md#mongodb-setting-security.authorization) enabled, you must have the [`clusterManager`](https://www.mongodb.com/docs/manual/reference/built-in-roles.md#mongodb-authrole-clusterManager) role or any role that includes the [`removeShard`](https://www.mongodb.com/docs/manual/reference/privilege-actions.md#mongodb-authaction-removeShard) action.

## Examples

To start draining a shard, use the [`db.adminCommand()`](https://www.mongodb.com/docs/manual/reference/method/db.admincommand.md#mongodb-method-db.adminCommand) method to run the [`startShardDraining`](https://www.mongodb.com/docs/manual/reference/command/startsharddraining.md#mongodb-dbcommand-dbcmd.startShardDraining) command:

```javascript
db.adminCommand( { startShardDraining: "shard04" } )
```

To stop draining the shard, use the [`db.adminCommand()`](https://www.mongodb.com/docs/manual/reference/method/db.admincommand.md#mongodb-method-db.adminCommand) method to run the `stopShardDraining` command:

```javascript
db.adminCommand( { stopShardDraining: "shard04" } )
```

## Learn More

- [`startShardDraining`](https://www.mongodb.com/docs/manual/reference/command/startsharddraining.md#mongodb-dbcommand-dbcmd.startShardDraining)

- [`shardDrainingStatus`](https://www.mongodb.com/docs/manual/reference/command/sharddrainingstatus.md#mongodb-dbcommand-dbcmd.shardDrainingStatus)

- [`commitShardRemoval`](https://www.mongodb.com/docs/manual/reference/command/commitshardremoval.md#mongodb-dbcommand-dbcmd.commitShardRemoval)
