Help Center> Document Database Service> FAQs> Database Connection> What Can I Do If the Number of Connections of an Instance Reaches Its Maximum?

What Can I Do If the Number of Connections of an Instance Reaches Its Maximum?

Message

  • If the following information is displayed when you use Mongo Shell to connect to a DB instance, the number of connections reaches its maximum.
    Figure 1 Message displayed
  • If the following information is displayed when you use Python to connect to a DB instance, the number of connections reaches its maximum.

    pymongo.errors.ServerSelectionTimeoutError: connection closed, connection closed

Solution 1

You can query the current number of connections on a node and the connection source, analyze the number of connections established between each client and the DB instance, and adjust the connections. For details, see How Do I Query and Limit the Number of Connections?.

Solution 2

You can change the maximum number of connections of a DB instance by modifying the net.maxIncomingConnections parameter. Then, restart the DB instance for the modification to take effect. For details about how to change parameter values, see Editing a Parameter Group.
  • If the value is default, the maximum number of connections is the default value and is related to the DB instance specifications. For details, see DB Instance Specifications.
  • If there are too many connections, the service may break down. In this case, you can only increase the number of connections by changing the DB instance specifications. For details, see Changing the CPU or Memory of a Cluster DB Instance.

If a parameter group is a default parameter group, you are not allowed to change its parameter values. You can create a parameter group and change the corresponding parameter values. After the change, associate the new parameter group with the DB instance. For details, see Changing Associated Parameter Group.