python network_error ai_generated true

aiohttp.client_exceptions.ClientConnectorSSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number

ID: python/aiohttp-client-connector-ssl-handshake-error

Also available as: JSON · Markdown · 中文
80%Fix Rate
83%Confidence
0Evidence
2025-11-18First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.10 active
3.11 active

Root Cause

The server is using an incompatible SSL/TLS version, or the client is trying to connect with HTTPS to an HTTP server.

generic

中文

服务器使用不兼容的 SSL/TLS 版本,或者客户端尝试使用 HTTPS 连接到 HTTP 服务器。

Workarounds

  1. 90% success Use the correct URL scheme (http:// instead of https://)
    async with session.get('http://example.com') as resp:
  2. 85% success Update the SSL context to use modern TLS versions
    import ssl
    ssl_context = ssl.create_default_context()
    ssl_context.minimum_version = ssl.TLSVersion.TLSv1_2
    connector = aiohttp.TCPConnector(ssl=ssl_context)
    async with aiohttp.ClientSession(connector=connector) as session:

Dead Ends

Common approaches that don't work:

  1. Disabling SSL verification with ssl=False 50% fail

    This does not fix the version mismatch; it only bypasses certificate verification.

  2. Using a very old SSL context that forces TLS 1.0 60% fail

    Many servers now reject outdated TLS versions due to security policies.