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

# Adjust Priority for a Self-Managed Replica Set Member

## Overview

The `priority` settings of replica set members affect both the timing and the outcome of [elections](https://www.mongodb.com/docs/manual/core/replica-set-elections.md#std-label-replica-set-election-internals) for primary. Higher-priority members are more likely to call elections, and are more likely to win. Use this setting to ensure that some members are more likely to become primary and that others can never become primary.

The value of the member's [`priority`](https://www.mongodb.com/docs/manual/reference/replica-configuration.md#mongodb-rsconf-rsconf.members-n-.priority) setting determines the member's [`priority`](https://www.mongodb.com/docs/manual/reference/replica-configuration.md#mongodb-rsconf-rsconf.members-n-.priority) in elections. The higher the number, the higher the priority.

## Considerations

To modify priorities, you update the [`members`](https://www.mongodb.com/docs/manual/reference/replica-configuration.md#mongodb-rsconf-rsconf.members) array in the replica configuration object. The array index begins with `0`. Do **not** confuse this index value with the value of the replica set member's [`members[n]._id`](https://www.mongodb.com/docs/manual/reference/replica-configuration.md#mongodb-rsconf-rsconf.members-n-._id) field in the array.

The value of [`priority`](https://www.mongodb.com/docs/manual/reference/replica-configuration.md#mongodb-rsconf-rsconf.members-n-.priority) can be any floating point (i.e. decimal) number between `0` and `1000`. The default value for the `priority` field is `1`.

To block a member from seeking election as primary, assign it a priority of `0`. [Hidden members](https://www.mongodb.com/docs/manual/core/replica-set-hidden-member.md#std-label-replica-set-hidden-members) and [delayed members](https://www.mongodb.com/docs/manual/core/replica-set-delayed-member.md#std-label-replica-set-delayed-members) have `priority` set to `0`.

Arbiters have priority `0`.

Adjust priority settings during a scheduled maintenance window. Reconfiguring priority can force the current primary to step down, leading to an election. Before an election, the primary closes all open [client](https://www.mongodb.com/docs/manual/reference/glossary.md#std-term-client) connections.

### Priority and Votes

[`members[n].priority`](https://www.mongodb.com/docs/manual/reference/replica-configuration.md#mongodb-rsconf-rsconf.members-n-.priority) and [`members[n].votes`](https://www.mongodb.com/docs/manual/reference/replica-configuration.md#mongodb-rsconf-rsconf.members-n-.votes) have the following relationship:

- Non-voting (i.e. [`votes`](https://www.mongodb.com/docs/manual/reference/replica-configuration.md#mongodb-rsconf-rsconf.members-n-.votes) is `0`) members must have [`priority`](https://www.mongodb.com/docs/manual/reference/replica-configuration.md#mongodb-rsconf-rsconf.members-n-.priority) of 0.

- Members with [`priority`](https://www.mongodb.com/docs/manual/reference/replica-configuration.md#mongodb-rsconf-rsconf.members-n-.priority) greater than 0 cannot have 0 [`votes`.](https://www.mongodb.com/docs/manual/reference/replica-configuration.md#mongodb-rsconf-rsconf.members-n-.votes)

As such, increasing a non-voting member's [`priority`](https://www.mongodb.com/docs/manual/reference/replica-configuration.md#mongodb-rsconf-rsconf.members-n-.priority) *requires* setting [`votes`](https://www.mongodb.com/docs/manual/reference/replica-configuration.md#mongodb-rsconf-rsconf.members-n-.votes) to `1` and increases the number of voting replica set members. Before increasing the priority of a non-voting member, consider the following:

- MongoDB replica sets can have no more than [7 voting members](https://www.mongodb.com/docs/manual/reference/limits.md#mongodb-limit-Number-of-Voting-Members-of-a-Replica-Set). If the replica set already has 7 voting members, you cannot modify the priority of any remaining members in the replica set to be greater than `0`.

- Replica reconfiguration can add or remove no more than *one* voting member at a time. To change multiple non-voting members to have a priority greater than `0`, issue a series of [`replSetReconfig`](https://www.mongodb.com/docs/manual/reference/command/replsetreconfig.md#mongodb-dbcommand-dbcmd.replSetReconfig) or [`rs.reconfig()`](https://www.mongodb.com/docs/manual/reference/method/rs.reconfig.md#mongodb-method-rs.reconfig) operations to modify one member at a time. See [Reconfiguration Can Add or Remove No More than One Voting Member at a Time](https://www.mongodb.com/docs/manual/reference/command/replsetreconfig.md#std-label-replSetReconfig-cmd-single-node) for more information.

## Procedure

**Warning:**

- The [`rs.reconfig()`](https://www.mongodb.com/docs/manual/reference/method/rs.reconfig.md#mongodb-method-rs.reconfig) shell method can force the current primary to step down, which causes an [election](https://www.mongodb.com/docs/manual/core/replica-set-elections.md#std-label-replica-set-elections). When the primary steps down, the [`mongod`](https://www.mongodb.com/docs/manual/reference/program/mongod.md#mongodb-binary-bin.mongod) closes all client connections. While this typically takes 10-20 seconds, try to make these changes during scheduled maintenance periods.

- Avoid reconfiguring replica sets that contain members of different MongoDB versions as validation rules may differ across MongoDB versions.

1. Copy the replica set configuration to a variable.

   In [`mongosh`](https://www.mongodb.com/docs/mongodb-shell.md#mongodb-binary-bin.mongosh), use [`rs.conf()`](https://www.mongodb.com/docs/manual/reference/method/rs.conf.md#mongodb-method-rs.conf) to retrieve the replica set configuration and assign it to a variable. For example:

   ```javascript
   cfg = rs.conf()

   ```

2. Change each member's priority value.

   Change each member's [`members[n].priority`](https://www.mongodb.com/docs/manual/reference/replica-configuration.md#mongodb-rsconf-rsconf.members-n-.priority) value, as configured in the [`members`](https://www.mongodb.com/docs/manual/reference/replica-configuration.md#mongodb-rsconf-rsconf.members) array.

   ```javascript
   cfg.members[0].priority = 0.5
   cfg.members[1].priority = 2
   cfg.members[2].priority = 2

   ```

   This sequence of operations modifies the value of `cfg` to set the priority for the first three members defined in the [`members`](https://www.mongodb.com/docs/manual/reference/replica-configuration.md#mongodb-rsconf-rsconf.members) array.

3. Assign the replica set the new configuration.

   Use [`rs.reconfig()`](https://www.mongodb.com/docs/manual/reference/method/rs.reconfig.md#mongodb-method-rs.reconfig) to apply the new configuration.

   ```javascript
   rs.reconfig(cfg)

   ```

   This operation updates the configuration of the replica set using the configuration defined by the value of `cfg`.
