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

# flushRouterConfig (database command)

## Definition

[`flushRouterConfig`](https://www.mongodb.com/docs/manual/reference/command/flushrouterconfig.md#mongodb-dbcommand-dbcmd.flushRouterConfig) marks the cached routing table for a sharded cluster as stale, causing the next operation that requests the routing table to refresh the cache. Management of the routing table cache is handled automatically by the cluster.

**Note:**

Running [`flushRouterConfig`](https://www.mongodb.com/docs/manual/reference/command/flushrouterconfig.md#mongodb-dbcommand-dbcmd.flushRouterConfig) is no longer required after executing [`movePrimary`](https://www.mongodb.com/docs/manual/reference/command/moveprimary.md#mongodb-dbcommand-dbcmd.movePrimary), [`dropDatabase`](https://www.mongodb.com/docs/manual/reference/command/dropdatabase.md#mongodb-dbcommand-dbcmd.dropDatabase), or [`db.collection.getShardDistribution()`](https://www.mongodb.com/docs/manual/reference/method/db.collection.getsharddistribution.md#mongodb-method-db.collection.getShardDistribution). These commands now automatically refresh a sharded cluster's routing table as needed when run.

## Compatibility

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

- [MongoDB Atlas](https://www.mongodb.com/docs/atlas): The fully managed service for MongoDB deployments in the cloud

* [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

## Syntax

The [`flushRouterConfig`](https://www.mongodb.com/docs/manual/reference/command/flushrouterconfig.md#mongodb-dbcommand-dbcmd.flushRouterConfig) is available on both [`mongos`](https://www.mongodb.com/docs/manual/reference/program/mongos.md#mongodb-binary-bin.mongos) and [`mongod`](https://www.mongodb.com/docs/manual/reference/program/mongod.md#mongodb-binary-bin.mongod) instances, and has the following syntax:

- Flush the cache for a specified collection when passed in a collection namespace parameter:

  ```javascript
  db.adminCommand(
     {
       flushRouterConfig: "<db.collection>"
     }
  )
  ```

- Flush the cache for a specified database and all of its collections when passed in a database namespace parameter:

  ```javascript
  db.adminCommand(
     {
       flushRouterConfig: "<db>"
     }
  )
  ```

- Flush the cache for all databases and their collections when run without a parameter or passed in a non-string scalar value (e.g. `1`):

  ```javascript
  db.adminCommand("flushRouterConfig")
  db.adminCommand(
     {
       flushRouterConfig: 1
     }
  )
  ```

## Access Control

The `flushRouterConfig` command requires the [`flushRouterConfig`](https://www.mongodb.com/docs/manual/reference/privilege-actions.md#mongodb-authaction-flushRouterConfig) privilege action on the `cluster` resource.

This privilege action is also available to users with the following roles:

- [`clusterManager`](https://www.mongodb.com/docs/manual/reference/built-in-roles.md#mongodb-authrole-clusterManager)

- [`hostManager`](https://www.mongodb.com/docs/manual/reference/built-in-roles.md#mongodb-authrole-hostManager)
