{"record":{"id":"654de1f0e10e3b3f","repo":"redis/redis-py","slug":"no-connection-available","errorCode":null,"errorMessage":"No connection available.","messagePattern":"No connection available\\.","errorType":"exception","errorClass":"ConnectionError","httpStatus":null,"severity":"error","filePath":"redis/asyncio/connection.py","lineNumber":3103,"sourceCode":"        start_time_acquired = time.monotonic()\n\n        try:\n            async with self._condition:\n                async with async_timeout(self.timeout):\n                    await self._condition.wait_for(self.can_get_connection)\n                    async with self._maybe_pool_lock():\n                        # Track connection count before to detect if a new connection is created\n                        connections_before = len(self._available_connections) + len(\n                            self._in_use_connections\n                        )\n                        start_time_created = time.monotonic()\n                        connection = super().get_available_connection()\n                        connections_after = len(self._available_connections) + len(\n                            self._in_use_connections\n                        )\n                        is_created = connections_after > connections_before\n        except asyncio.TimeoutError as err:\n            raise ConnectionError(\"No connection available.\") from err\n\n        # We now perform the connection check outside of the lock.\n        try:\n            await self.ensure_connection(connection)\n\n            if is_created:\n                await record_connection_create_time(\n                    connection_pool=self,\n                    duration_seconds=time.monotonic() - start_time_created,\n                )\n\n            await record_connection_wait_time(\n                pool_name=get_pool_name(self),\n                duration_seconds=time.monotonic() - start_time_acquired,\n            )\n\n            return connection\n        except BaseException:","sourceCodeStart":3085,"sourceCodeEnd":3121,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/asyncio/connection.py#L3085-L3121","documentation":"BlockingConnectionPool.get_connection waits on an asyncio condition up to 'timeout' seconds; if no connection frees up in time it raises ConnectionError('No connection available.') wrapping the asyncio.TimeoutError. With timeout=None the pool blocks forever and this error never fires. It differs from the plain pool's MaxConnectionsError in that it is a wait-timeout, not an immediate capacity rejection.","triggerScenarios":"Using a BlockingConnectionPool where all connections stay in use longer than the configured timeout (default 20s), so the condition wait_for times out.","commonSituations":"blocking_timeout too short for the workload; long-running commands; connection leaks where holders never release; deadlock between concurrent commands.","solutions":["Increase the pool's timeout to match realistic command latency.","Increase max_connections to cover peak concurrency.","Ensure connections are released promptly (try/finally or 'async with').","Catch ConnectionError and retry with backoff."],"exampleFix":"# before\npool = BlockingConnectionPool(host='redis.local', max_connections=10, timeout=2)\n# after\npool = BlockingConnectionPool(host='redis.local', max_connections=50, timeout=30)","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"from redis.exceptions import ConnectionError\nfor attempt in range(retries):\n    try:\n        return await client.get(key)\n    except ConnectionError as e:\n        if 'No connection available' not in str(e):\n            raise\n        await asyncio.sleep(backoff(attempt))\nraise","preventionTips":["Set BlockingConnectionPool.timeout to exceed your worst-case command latency.","Release connections in finally blocks; monitor pool saturation."],"tags":["connection-pool","timeout","capacity","async"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}