Minor issues tips & tricks

Too many clients already error in dockerized PSQL database container

To fix this issue:

  1. Stop currently running containers

    • docker-compose down

    • ctrl + c if you ran compose without -d flag

  2. Add command: postgres -c 'max_connections=250' to database container definition in docker-compose.yml

  3. Re-run app

    • docker-compose up -d

  4. You can now investigate how many connections are really needed and lower that value

To investigate how many connections are occupied:

  1. Run app (if you have not started it yet)

    • docker-compose up -d

  2. List all running containers to get database CONTAINER_ID (it contains postgres in image name)

    • docker ps

  3. Check database container ip

    • docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' CONTAINER_ID

  4. Connect locally to database container, write container ip in host name input (use database client, I have used dbeaver)

  5. Right click on database/SQL Editor/Open SQL console

  6. To check current connections to database

    • select * from pg_catalog.pg_stat_activity

OpenLMIS: the global initiative for powerful LMIS software