Docs Menu

Docs HomeMongoDB Manual


On this page

  • Definition
  • Syntax
  • Behavior
  • Example

New in version 3.4.

The removeShardFromZone administrative command removes the association between a shard and a zone.

You can only run removeShardFromZone on the admin database from a mongos instance.

The removeShardFromZone command has the following syntax:

removeShardFromZone: <string>,
zone: <string>

The command takes the following fields:


The name of the shard from which to remove the zone association.


The name of the zone whose association with the shard you want to remove.

mongosh provides the helper method sh.removeShardFromZone().

removeShardFromZone does not remove ranges associated with the zone.

To completely remove a zone from the cluster, you must run removeShardFromZone on each shard associated with the zone.

If the shard specified is the last shard associated with the zone, you must ensure there are no remaining shard key ranges associated with the zone. Use updateZoneKeyRange to remove any existing ranges associated with the zone before running removeShardFromZone.

See the zone manual page for more information on zones in sharded clusters.

For sharded clusters that enforce access control, you must authenticate either as:

  • a user whose privileges include:

    • update on the shards collection in the config database, and

    • find on the tags collection in the config database;

    or, alternatively

  • a user whose privileges include enableSharding on the cluster resource (available starting in version 4.2.2, 4.0.14, 3.6.16).

The clusterAdmin or clusterManager built-in roles have the appropriate permissions for issuing removeShardFromZone. See the Role-Based Access Control manual page for more information.

The following example removes the association between shard0000 and zone NYC:

db.adminCommand( { removeShardFromZone : "shard0000" , zone : "NYC" } )
←  removeShardreshardCollection →
Share Feedback
© 2023 MongoDB, Inc.


  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2023 MongoDB, Inc.