redis/redis-py · error · RedisError
Hiredis is not available.
Error message
Hiredis is not available.
What it means
Raised by _AsyncHiredisParser.__init__ when redis.utils.HIREDIS_AVAILABLE is False: the optional hiredis C extension is either not installed or older than 3.2.0 (the minimum this library will use, per utils.py). The parser cannot operate without it, so construction fails fast with redis.exceptions.RedisError before any connection is attempted.
Source
Thrown at redis/_parsers/hiredis.py:276
)
elif (
isinstance(response, list)
and response
and isinstance(response[0], ConnectionError)
):
raise response[0]
return response
class _AsyncHiredisParser(AsyncBaseParser, AsyncPushNotificationsParser):
"""Async implementation of parser class for connections using Hiredis"""
__slots__ = ("_reader",)
def __init__(self, socket_read_size: int):
if not HIREDIS_AVAILABLE:
raise RedisError("Hiredis is not available.")
super().__init__(socket_read_size=socket_read_size)
self._reader = None
self.pubsub_push_handler_func = self.handle_pubsub_push_response
self.invalidation_push_handler_func = None
self._hiredis_PushNotificationType = None
async def handle_pubsub_push_response(self, response):
logger = getLogger("push_response")
logger.debug("Push response: %s", response)
return response
def on_connect(self, connection):
import hiredis
self._stream = connection._reader
kwargs: _HiredisReaderArgs = {
"protocolError": InvalidResponse,
"replyError": self.parse_error,View on GitHub (pinned to 6a6b581b48)
Solutions
- Install/upgrade the optional dependency: pip install -U 'hiredis>=3.2.0' (or 'redis[hiredis]').
- Don't force parser_class - omit it and let the library auto-select hiredis when available, else the pure-Python parser.
- Verify the import actually works: python -c 'import hiredis; print(hiredis.__version__)'.
- On platforms lacking a wheel, install a build toolchain (gcc / python3-dev) or drop the forced hiredis parser.
Example fix
# before import redis.asyncio as redis from redis._parsers.hiredis import _AsyncHiredisParser r = redis.Redis(parser_class=_AsyncHiredisParser) # -> RedisError: Hiredis is not available. # after - install the extra and let the library choose # pip install 'redis[hiredis]' r = redis.Redis() # uses hiredis if present, pure-Python otherwise
Defensive patterns
Strategy: validation
Validate before calling
import redis.utils
from redis._parsers.hiredis import _AsyncHiredisParser
if not redis.utils.HIREDIS_AVAILABLE:
raise SystemExit('install: pip install "redis[hiredis]"')
r = redis.Redis(parser_class=_AsyncHiredisParser) Type guard
from redis.exceptions import RedisError
def is_missing_dep_error(e: BaseException) -> bool:
return isinstance(e, RedisError) and 'not available' in str(e).lower() Try / catch
import redis.utils parser = _AsyncHiredisParser if redis.utils.HIREDIS_AVAILABLE else None r = redis.Redis(parser_class=parser) if parser else redis.Redis()
Prevention
- Pin 'hiredis>=3.2.0' in your requirements if you force the hiredis parser.
- Install via the extra - 'pip install redis[hiredis]' - not bare 'pip install hiredis'.
- Don't hard-set parser_class in code that runs in heterogeneous environments; let it auto-select.
When it happens
Trigger: Passing parser_class=_AsyncHiredisParser (or otherwise forcing the hiredis parser) without the dependency; deploying where 'pip install redis[hiredis]' was skipped or the hiredis wheel failed to build/import; downgrading hiredis below 3.2.0; a platform without a hiredis wheel (some archs/PyPy) and no build toolchain.
Common situations: Slender Docker image that pip-installed 'redis' but not 'redis[hiredis]'; Alpine/musl without gcc to build hiredis; Python 3.13 with an old pinned hiredis that lacks a wheel; a CI matrix pining hiredis<3.2.
Related errors
- Hiredis is not installed
- Maintenance notifications are not supported with Unix domain
- Buffer is closed.
- 'username' and 'password' cannot be passed along with 'crede
- protocol must be an integer
AI-assisted analysis of redis/redis-py@6a6b581b48 (2026-08-10).
Data as JSON: /api/errors/47162a9d15b06624.
Report an issue: GitHub.