Problem description

The client cannot connect to the apsaradb RDS for PostgreSQL instance because the client has established an excessive number of connections. The following error is returned:

FATAL: remaining connection slots are reserved for non-replication superuser connections


Alibaba Cloud reminds you that:

  • When you perform operations that have risks, such as modifying instances or data, check the disaster recovery and fault tolerance capabilities of the instances to ensure data security.
  • Before you modify the configurations and data of instances including but not limited to ECS and RDS instances, we recommend that you create snapshots or enable RDS log backup.
  • If you have authorized or submitted security information such as the logon account and password in the Alibaba Cloud Management console, we recommend that you modify such information in a timely manner.

If there are remaining session windows, perform the following steps to terminate the connection count process for the remaining session windows. If there are no remaining connection sessions and it is inconvenient to restart the instance, submit a ticket contact Alibaba Cloud technical support personnel.

  1. Select SQL operations> SQL window. Run the following SQL statement to check the limit of the current number of connections:
    show max_connections
  2. Run the following SQL statement to view the current number of connections and record the number of connections to be terminated: PID.
    select * from pg_stat_activity;
  3. Run the following SQL statement to end the connections process:
    SELECT pg_terminate_backend([$PID]) FROM pg_stat_activity;
    Note:[$PID] indicates the PID that is recorded in the preceding steps. PID.

Application scope

  • Apsaradb RDS for PostgreSQL