{"record":{"id":"2ced58bfb6fc5b41","repo":"redis/redis-py","slug":"redis-url-must-specify-one-of-the-following-scheme-2ced58","errorCode":null,"errorMessage":"Redis URL must specify one of the following schemes (redis://, rediss://, unix://)","messagePattern":"Redis URL must specify one of the following schemes \\(redis://, rediss://, unix://\\)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"redis/connection.py","lineNumber":2351,"sourceCode":"    \"retry_on_error\": list,\n    \"max_connections\": int,\n    \"health_check_interval\": int,\n    \"ssl_check_hostname\": to_bool,\n    \"ssl_include_verify_flags\": parse_ssl_verify_flags,\n    \"ssl_exclude_verify_flags\": parse_ssl_verify_flags,\n    \"ssl_min_version\": int,\n    \"timeout\": float,\n    \"protocol\": int,\n    \"legacy_responses\": to_bool,\n}\n\n\ndef parse_url(url):\n    # Scheme names are case-insensitive (RFC 3986), so normalize before the\n    # prefix check; the \"://\" is required so a URL like \"redis:foo\" (which\n    # urlparse would still report as the \"redis\" scheme) is rejected.\n    if not url.lower().startswith((\"redis://\", \"rediss://\", \"unix://\")):\n        raise ValueError(\n            \"Redis URL must specify one of the following \"\n            \"schemes (redis://, rediss://, unix://)\"\n        )\n\n    url = urlparse(url)\n    kwargs = {}\n\n    for name, value in parse_qs(url.query).items():\n        if value and len(value) > 0:\n            # parse_qs() already percent-decodes query values, so use the value\n            # as-is; unquoting again here would double-decode (e.g. \"%2520\" ->\n            # \"%20\" -> \" \"). See issue #4208.\n            value = value[0]\n            parser = URL_QUERY_ARGUMENT_PARSERS.get(name)\n            if parser:\n                try:\n                    kwargs[name] = parser(value)\n                except (TypeError, ValueError):","sourceCodeStart":2333,"sourceCodeEnd":2369,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/connection.py#L2333-L2369","documentation":"Raised as ValueError by parse_url when the URL does not start (case-insensitively) with redis://, rediss://, or unix://. The check requires the '://' so a bare scheme like 'redis:foo' is also rejected. redis-py only supports these three schemes; anything else is a configuration error.","triggerScenarios":"Calling redis.Redis.from_url('localhost:6379'), from_url('redis:localhost'), from_url('tcp://host'), or from_url('') — any string missing a recognized scheme prefix.","commonSituations":"Forgetting the scheme and passing host:port. Using an env var that was meant for another client (e.g. a 'tcp://' or 'redis-cluster://' URL). Trailing/leading whitespace in the env var. Empty REDIS_URL.","solutions":["Prefix the value with redis:// (e.g. redis://localhost:6379/0), rediss:// for TLS, or unix:///path/to/socket.sock.","Strip whitespace from environment-supplied URLs before passing them in.","If you have a bare host/port, use redis.Redis(host=..., port=...) instead of from_url."],"exampleFix":"# before\nr = redis.Redis.from_url(os.environ['REDIS_HOST'])  # e.g. 'localhost:6379'\n# after\nr = redis.Redis.from_url('redis://' + os.environ['REDIS_HOST'])","handlingStrategy":"validation","validationCode":"def is_supported_redis_url(url: str) -> bool:\n    return isinstance(url, str) and url.lower().startswith(('redis://', 'rediss://', 'unix://'))\n\nurl = os.environ.get('REDIS_URL', '').strip()\nif not is_supported_redis_url(url):\n    raise ValueError(f'REDIS_URL must start with redis://, rediss://, or unix:// — got {url!r}')\nr = redis.Redis.from_url(url)","typeGuard":"def is_supported_redis_url(url) -> bool:\n    return isinstance(url, str) and url.lower().startswith(('redis://', 'rediss://', 'unix://'))","tryCatchPattern":"try:\n    r = redis.Redis.from_url(maybe_url)\nexcept ValueError as e:\n    if 'must specify one of the following schemes' in str(e):\n        maybe_url = 'redis://' + maybe_url\n        r = redis.Redis.from_url(maybe_url)\n    else:\n        raise","preventionTips":["Always include the scheme in REDIS_URL.","Strip whitespace from env-supplied URLs.","Validate the scheme at app startup before constructing clients."],"tags":["configuration","url-parsing","validation"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}