Logo
ХелпдескУправление знаниямиБизнесуТарифыЧто такое KCS?Блог
Русский
Личный кабинет
Настройка системы
© 2023 - 2026 ООО «Свормика». Swarmica - Платформа управления знаниями и ресурсами техподдержки. Версия: 6.1.2

#1127: FATAL error: sorry, too many clients already

Отредактирована: сегодня

Symptoms

Periodically, the error [object Object] appears in the interface

In the Network tab, some requests fail with error 500 Internal error has occurred

In the postgres container logs, the error is FATAL: sorry, too many clients already

Solution

Increase the number of connections for postgres

  1. In the docker-compose.yml configuration file, in the postgres section, edit the value of the N parameter:
  postgres:
    image: postgres:14.2-bullseye
    container_name: swarmica-postgres
    shm_size: 4gb
    command: postgres -N 300 -c shared_preload_libraries=pg_stat_statements -c pg_stat_statements.track=all -c wal_keep_size=512MB -c work_mem=8MB -c temp_buffers=16MB -c shared_buffers=4GB -c track_activity_query_size=16384
    restart: always
    volumes:
      - swarmica_postgres_data:/var/lib/postgresql/data:Z
      - swarmica_postgres_data_backups:/backups:z
      - ./pg_hba.conf:/var/lib/postgresql/data/pg_hba.conf
    env_file:
      - .env
    ports:
      - "5432:5432"

Important The number N * work_mem should not exceed the size of shared_buffers! Also, it is important to consider the amount of free memory on the server. If free -lmt shows that more than 20% of memory is used in Swap, this means that the server does not have enough memory and before increasing the number of connections, you need to add RAM

  1. Restart the application docker compose down && docker compose up -d

Cause

The allowed number of connections to the database has been exceeded. This can happen if the server has a heavy load in terms of the number of simultaneous users.