Docs Menu
Docs Home
/ /

Localhost Exception in Self-Managed Deployments

Important

On a mongod instance, the localhost exception only applies when there are no users or roles created in the MongoDB instance.

The localhost exception allows you to create the first user or role in the system after enabling access control. You can also use it to initiate a replica set.

You can use the localhost exception to initiate a replica set, following the steps in Deploy a Self-Managed Replica Set. You must wait until the replica set elects a primary before you can add the first user.

Warning

Connections using the localhost exception have access to create only the first user OR role. Only create a role first if you are authorizing users with LDAP. See LDAP Authorization for more information.

After you enable access control, connect to the localhost interface and create the first user in the admin database. The first user must have privileges to create other users. The userAdmin or userAdminAnyDatabase role both confer the privilege to create other users.

Important

  • On a mongos, the localhost exception only applies when there are no sharded cluster users or roles created.

  • In a sharded cluster, the localhost exception applies to each shard individually as well as to the cluster as a whole.

Once you create a sharded cluster and add a user administrator through the mongos instance, you must still prevent unauthorized access to the individual shards. To prevent unauthorized access to individual shards, follow one of the following steps for each shard in your cluster:

While the localhost exception applies, you can:

Back

Rotate X.509 to Use Extension Values

On this page