Unable to Add Additional External Databases

Product version: 10.6

Last modified: 19 January 2022

Problem

When attempting to perform migration to a PostgreSQL Database, the task fails with the following error:

FATAL: sorry, too many clients already

Background

This above message is a generic error returned by the PostgreSQL server when a connection limit is reached. That is to say, the PostgreSQL server—not the specific database—cannot support another connection (in this case, from NAKIVO Backup & Replication) as it would exceed the connection limit established in the server properties. To check this limit, query the following in SQL:

show max_connections;

Solution

To fix the issue and establish a connection to the relevant external database, first check the the nature and number of all open connections. For a list of active connections, query the following:

SELECT * FROM pg_stat_activity;

You can quickly count the number of connections with the following:

SELECT COUNT(*) FROM pg_stat_activity;

From here, you have two options, depending on the nature of the issue:

  • Close idle open connections: this option is applicable when a large number of connections seem to be occupied by processes that have not been properly cleared in the server. To properly release connections, make sure to include the applicable command to close idle connections or add an idle timeout value—these may vary based on your version of PostgreSQL.

  • Increase the maximum number of connections: this option is applicable when you require a larger number of connections to the server than your settings currently allow. To increase this value, proceed as follows:

    1. Locate and open your postgresql.conf file. You can check its location by running:

      SHOW config_file;

    2. Find max_connections and increase this value to an applicable number.

    3. Reboot the server and try migrating your NAKIVO Backup & Replication again. Retry these steps if the same error occurs.