{
  "id": "python/aiohttp-client-connection-pool-exhausted",
  "signature": "aiohttp.client_exceptions.ClientConnectionError: Cannot connect to host example.com:443 ssl:default [Connection refused]",
  "signature_zh": "aiohttp.client_exceptions.ClientConnectionError：无法连接到主机 example.com:443 ssl:default [连接被拒绝]",
  "regex": "aiohttp\\.client_exceptions\\.ClientConnectionError:\\ Cannot\\ connect\\ to\\ host\\ example\\.com:443\\ ssl:default\\ \\[Connection\\ refused\\]",
  "domain": "python",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "The connection pool limit is reached or the server refuses connections due to too many simultaneous requests, often because ClientSession's connector limit is too low or connections are not released.",
  "root_cause_type": "generic",
  "root_cause_zh": "连接池达到限制或服务器因并发请求过多而拒绝连接，通常是因为 ClientSession 的连接器限制过低或连接未释放。",
  "versions": [
    {
      "version": "3.8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.9",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Higher limit can lead to resource exhaustion and doesn't address server-side refusal.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Creates many sessions, each with its own pool, causing overhead and still hitting OS limits.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.85,
      "how": "connector = aiohttp.TCPConnector(limit=100, limit_per_host=20)\nasync with aiohttp.ClientSession(connector=connector) as session:\n    # use session for multiple requests",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "for attempt in range(3):\n    try:\n        async with session.get(url) as resp:\n            return await resp.text()\n    except aiohttp.ClientConnectionError:\n        if attempt == 2:\n            raise\n        await asyncio.sleep(2 ** attempt)",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-04-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}