{"record":{"id":"23009cf77ccd8efa","repo":"aio-libs/aiohttp","slug":"no-proxies-found-for-url-s-in-the-env","errorCode":null,"errorMessage":"No proxies found for `{url!s}` in the env","messagePattern":"No proxies found for `(.+?)` in the env","errorType":"exception","errorClass":"LookupError","httpStatus":null,"severity":"warning","filePath":"aiohttp/helpers.py","lineNumber":299,"sourceCode":"            if proxy.host is not None:\n                try:\n                    auth = _auth_header_from_netrc(netrc_obj, proxy.host)\n                except LookupError:\n                    auth = None\n        ret[proto] = ProxyInfo(proxy, auth)\n    return ret\n\n\ndef get_env_proxy_for_url(url: URL) -> tuple[URL, str | None]:\n    \"\"\"Get a permitted proxy for the given URL from the env.\"\"\"\n    if url.host is not None and proxy_bypass(url.host):\n        raise LookupError(f\"Proxying is disallowed for `{url.host!r}`\")\n\n    proxies_in_env = proxies_from_env()\n    try:\n        proxy_info = proxies_in_env[url.scheme]\n    except KeyError:\n        raise LookupError(f\"No proxies found for `{url!s}` in the env\")\n    else:\n        return proxy_info.proxy, proxy_info.proxy_auth\n\n\n@frozen_dataclass_decorator\nclass MimeType:\n    type: str\n    subtype: str\n    suffix: str\n    parameters: \"MultiDictProxy[str]\"\n\n\n@functools.lru_cache(maxsize=56)\ndef parse_mimetype(mimetype: str) -> MimeType:\n    \"\"\"Parses a MIME type into its components.\n\n    mimetype is a MIME type string.\n","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/aio-libs/aiohttp/blob/d041d4d0fd48c3f0832084d33be16cf1c4835f85/aiohttp/helpers.py#L281-L317","documentation":"get_env_proxy_for_url raises LookupError when no proxy environment variable (HTTP_PROXY/http_proxy/HTTPS_PROXY/https_proxy) matches the URL's scheme. After confirming the host is not bypassed, the function looks up the scheme in the proxies-from-env dict and raises if the key is missing.","triggerScenarios":"Calling get_env_proxy_for_url for an https:// URL when only HTTP_PROXY is set (not HTTPS_PROXY), or vice versa. Also triggered for non-standard schemes like ftp:// when no matching proxy env var exists.","commonSituations":"HTTP_PROXY is set but HTTPS_PROXY is missing, and the code makes an HTTPS request; env var case mismatch (some systems need lowercase http_proxy); proxy env vars not propagated into a container or subprocess.","solutions":["Set both HTTP_PROXY and HTTPS_PROXY environment variables","Ensure env var names match the expected scheme (HTTPS_PROXY for https:// URLs)","Pass the proxy explicitly: session.get(url, proxy='http://proxy:8080')","Check for typos in env var names (e.g. HTTPS_PROXY vs HTTPS_PROXY)"],"exampleFix":"# before (only HTTP_PROXY set, request is HTTPS)\nexport HTTP_PROXY=http://proxy:3128\n# session.get('https://api.example.com/data') raises\n\n# after\nexport HTTP_PROXY=http://proxy:3128\nexport HTTPS_PROXY=http://proxy:3128","handlingStrategy":"validation","validationCode":"import os\n\ndef get_proxy_for_scheme(scheme):\n    key = f'{scheme.upper()}_PROXY'\n    return os.environ.get(key) or os.environ.get(key.lower())\n\nproxy = get_proxy_for_scheme(url.scheme)\nif proxy is None:\n    logger.warning('No proxy env var for scheme %s', url.scheme)","typeGuard":null,"tryCatchPattern":"from aiohttp.helpers import get_env_proxy_for_url\ntry:\n    proxy, proxy_auth = get_env_proxy_for_url(url)\nexcept LookupError as e:\n    if 'No proxies found' in str(e):\n        proxy, proxy_auth = None, None  # direct connection\n    raise","preventionTips":["Set both HTTP_PROXY and HTTPS_PROXY in environments that use proxies","Verify env var propagation in containers and subprocesses","Use explicit proxy= parameter for deterministic proxy behavior"],"tags":["proxy","environment","configuration","env-vars"],"backgroundTag":null,"analyzedSha":"d041d4d0fd48c3f0832084d33be16cf1c4835f85","analyzedAt":"2026-08-11T20:44:15.550Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}