redis/redis-py · critical · RedisError

Python wasn't built with SSL support

Error message

Python wasn't built with SSL support

What it means

Raised as a RedisError from SSLConnection.__init__ when the module-level flag SSL_AVAILABLE is False - i.e. the running Python interpreter was compiled without the ssl module. Constructing an SSLConnection (via rediss:// URL, ssl=True, or connection_class=SSLConnection) is impossible because there is no ssl module to build an SSLContext from.

Source

Thrown at redis/asyncio/connection.py:1535

    def __init__(
        self,
        ssl_keyfile: Optional[str] = None,
        ssl_certfile: Optional[str] = None,
        ssl_cert_reqs: Union[str, ssl.VerifyMode] = "required",
        ssl_include_verify_flags: Optional[List["ssl.VerifyFlags"]] = None,
        ssl_exclude_verify_flags: Optional[List["ssl.VerifyFlags"]] = None,
        ssl_ca_certs: Optional[str] = None,
        ssl_ca_data: Optional[str] = None,
        ssl_ca_path: Optional[str] = None,
        ssl_check_hostname: bool = True,
        ssl_min_version: Optional[TLSVersion] = None,
        ssl_ciphers: Optional[str] = None,
        ssl_password: Optional[str] = None,
        **kwargs,
    ):
        if not SSL_AVAILABLE:
            raise RedisError("Python wasn't built with SSL support")

        self.ssl_context: RedisSSLContext = RedisSSLContext(
            keyfile=ssl_keyfile,
            certfile=ssl_certfile,
            cert_reqs=ssl_cert_reqs,
            include_verify_flags=ssl_include_verify_flags,
            exclude_verify_flags=ssl_exclude_verify_flags,
            ca_certs=ssl_ca_certs,
            ca_data=ssl_ca_data,
            ca_path=ssl_ca_path,
            check_hostname=ssl_check_hostname,
            min_version=ssl_min_version,
            ciphers=ssl_ciphers,
            password=ssl_password,
        )
        super().__init__(**kwargs)

    def _connection_arguments(self) -> Mapping:

View on GitHub (pinned to da03cdc7e8)

Solutions

  1. Install/rebuild Python with OpenSSL available (apt-get install libssl-dev / dnf install openssl-devel, then recompile).
  2. Use a standard CPython distribution or official docker image that includes ssl.
  3. If SSL is genuinely unavailable, connect without TLS (redis:// instead of rediss://).
  4. In containers, ensure ca-certificates and openssl libs are installed.

Example fix

// before - python built without ssl
r = redis.asyncio.from_url("rediss://host:6379")

// after - rebuild python with ssl, then the same code works
r = redis.asyncio.from_url("rediss://host:6379")
Defensive patterns

Strategy: validation

Validate before calling

from redis.utils import SSL_AVAILABLE
def assert_tls_capable():
    if not SSL_AVAILABLE:
        raise RuntimeError("Python interpreter has no ssl module; cannot use rediss://")

Type guard

def tls_available() -> bool:
    from redis.utils import SSL_AVAILABLE
    return bool(SSL_AVAILABLE)

Try / catch

from redis.exceptions import RedisError
try:
    r = redis.asyncio.from_url("rediss://host")
except RedisError as e:
    if "SSL support" in str(e):
        # fall back to plaintext or rebuild interpreter
        r = redis.asyncio.from_url("redis://host")
    else:
        raise

Prevention

When it happens

Trigger: redis.asyncio.from_url('rediss://...'), Redis(ssl=True), or explicitly passing connection_class=SSLConnection on a Python build where 'import ssl' fails. SSL_AVAILABLE is computed at import time in redis.utils.

Common situations: Custom/slim Python builds (--disable-ssl or missing OpenSSL headers at build time); some embedded interpreters; minimal distroless images lacking libssl; Python compiled against an incompatible OpenSSL; CI matrices with a 'no-ssl' variant.

Related errors


AI-assisted analysis of redis/redis-py@da03cdc7e8 (2026-08-04). Data as JSON: /data/errors/84aa1fa270742847.json. Report an issue: GitHub.