{"id":"206411a6b31ddd6b","repo":"aio-libs/aiohttp","slug":"no-entry-for-host-s-found-in-the-netrc-file","errorCode":null,"errorMessage":"No entry for {host!s} found in the `.netrc` file.","messagePattern":"No entry for (.+?) found in the `\\.netrc` file\\.","errorType":"exception","errorClass":"LookupError","httpStatus":null,"severity":"warning","filePath":"aiohttp/helpers.py","lineNumber":247,"sourceCode":"\n@frozen_dataclass_decorator\nclass ProxyInfo:\n    proxy: URL\n    proxy_auth: str | None\n\n\ndef _auth_header_from_netrc(netrc_obj: netrc.netrc | None, host: str) -> str:\n    \"\"\"Return a ``Proxy-Authorization`` header value for ``host`` from netrc.\n\n    :raises LookupError: if ``netrc_obj`` is :py:data:`None` or if no\n            entry is found for the ``host``.\n    \"\"\"\n    if netrc_obj is None:\n        raise LookupError(\"No .netrc file found\")\n    auth_from_netrc = netrc_obj.authenticators(host)\n\n    if auth_from_netrc is None:\n        raise LookupError(f\"No entry for {host!s} found in the `.netrc` file.\")\n    login, account, password = auth_from_netrc\n\n    # TODO(PY311): username = login or account\n    # Up to python 3.10, account could be None if not specified,\n    # and login will be empty string if not specified. From 3.11,\n    # login and account will be empty string if not specified.\n    username = login if (login or account is None) else account\n\n    # TODO(PY311): Remove this, as password will be empty string\n    # if not specified\n    if password is None:\n        password = \"\"  # type: ignore[unreachable]\n\n    return encode_basic_auth(username, password)\n\n\ndef proxies_from_env() -> dict[str, ProxyInfo]:\n    proxy_urls = {","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/aio-libs/aiohttp/blob/c0ef574e29109210e96e652771ae4e7b88615fa4/aiohttp/helpers.py#L229-L265","documentation":"Raised by _auth_header_from_netrc when the .netrc loaded successfully but netrc.authenticators(host) returns None, meaning no 'machine', 'default', or matching entry exists for that host. LookupError, indicating the host simply isn't covered by the file.","triggerScenarios":"A proxy host has no matching 'machine <host>' line and no 'default' line in .netrc. The client attempted netrc-based proxy auth and could not find credentials for the specific proxy host.","commonSituations":"Typo in the machine hostname in .netrc; using an IP in code but a FQDN in netrc; relying on 'default' that was forgotten; proxy host changed after refactor.","solutions":["Add a 'machine <exact-proxy-host> login <u> password <p>' line to .netrc.","Add a 'default' fallback line if appropriate.","Ensure the hostname string matches what getproxies() reports (host part of the proxy URL)."],"exampleFix":"// before\n# .netrc has: machine otherproxy login x password y\n// after\n# .netrc add: machine correctproxy.example.com login x password y","handlingStrategy":"validation","validationCode":"import netrc\nnrc = netrc.netrc()\nif nrc.authenticators(host) is None:\n    raise LookupError(f'add a machine {host} entry to .netrc')","typeGuard":null,"tryCatchPattern":"try:\n    auth = _auth_header_from_netrc(netrc_obj, host)\nexcept LookupError:\n    auth = None","preventionTips":["Use the exact proxy hostname in the 'machine' line.","Add a 'default' line as a last-resort credential source.","Keep host strings normalized (lowercase FQDN) between config and code."],"tags":["netrc","proxy","auth","config"],"analyzedSha":"c0ef574e29109210e96e652771ae4e7b88615fa4","analyzedAt":"2026-08-04T19:51:05.467Z","schemaVersion":2}