docker,

How to fix 'WARNING: Connection pool is full' in Docker Compose

Feb 23, 2022 · 1 min read · Post a comment
How to fix 'WARNING: Connection pool is full' in Docker Compose

If you have been working with docker-compose stacks for a while, you might have come across the following warning message: WARNING: Connection pool is full, discarding connection <IP Address>. Usually, the root cause it’s due to an application connection pool misconfiguration between the maximum number of connections in a pool and the number of requests running in parallel.

Prerequisites

  • Docker
  • Docker Compose

Solution(s)

Solution 1. Try to recreate the stack and remove any unused networks.

docker-compose down
docker network prune
docker-compose up -d

Solution 2. Alternately, increase the limit for the number of tasks/operations that could be run in parallel. Although the default value is 64 according to the docs, increasing parameter values is not always the best practice approach, but it might work. So, here are a few ways to override the COMPOSE_PARALLEL_LIMIT value.

From the CLI, as an environment variable on your host machine:

export COMPOSE_PARALLEL_LIMIT=100

A much better approach would be to include it in an .env file by being referenced in a docker-compose file. For instance:

#.env
COMPOSE_HTTP_TIMEOUT=100

Solution 3. Increase the connection pool in the application itself (not recommended).

Conclusion

If there is a better solution or approach, let me know in the comments below.
On a side note, follow our official channel on Telegram.