{"record":{"id":"acbe0301813aaa4e","repo":"python/cpython","slug":"can-not-get-address-information","errorCode":null,"errorMessage":"can not get address information","messagePattern":"can not get address information","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"Lib/asyncio/base_events.py","lineNumber":1463,"sourceCode":"                            addr, family=family, type=socket.SOCK_DGRAM,\n                            proto=proto, flags=flags, loop=self)\n                        if not infos:\n                            raise OSError('getaddrinfo() returned empty list')\n\n                        for fam, _, pro, _, address in infos:\n                            key = (fam, pro)\n                            if key not in addr_infos:\n                                addr_infos[key] = [None, None]\n                            addr_infos[key][idx] = address\n\n                # each addr has to have info for each (family, proto) pair\n                addr_pairs_info = [\n                    (key, addr_pair) for key, addr_pair in addr_infos.items()\n                    if not ((local_addr and addr_pair[0] is None) or\n                            (remote_addr and addr_pair[1] is None))]\n\n                if not addr_pairs_info:\n                    raise ValueError('can not get address information')\n\n            exceptions = []\n\n            for ((family, proto),\n                 (local_address, remote_address)) in addr_pairs_info:\n                sock = None\n                r_addr = None\n                try:\n                    sock = socket.socket(\n                        family=family, type=socket.SOCK_DGRAM, proto=proto)\n                    if reuse_port:\n                        _set_reuseport(sock)\n                    if allow_broadcast:\n                        sock.setsockopt(\n                            socket.SOL_SOCKET, socket.SO_BROADCAST, 1)\n                    sock.setblocking(False)\n\n                    if local_addr:","sourceCodeStart":1445,"sourceCodeEnd":1481,"githubUrl":"https://github.com/python/cpython/blob/bc6749cc3b5ae4a5e88a6cc2d5b3bebbe354eae6/Lib/asyncio/base_events.py#L1445-L1481","documentation":"Raised by create_datagram_endpoint() when local_addr and remote_addr resolve to disjoint sets of (family, proto) pairs. Endpoints require at least one common family — e.g. local resolves only to IPv4 while remote resolves only to IPv6 — so no (family, proto) pair can host both addresses.","triggerScenarios":"local_addr=('127.0.0.1', p) with remote_addr=('::1', q); or local resolves only IPv6 (single-stack /etc/hosts) while remote is IPv4-only.","commonSituations":"Hardcoded loopback literals mixing 127.0.0.1 and ::1; hosts files where one side has only one family record; dual-stack misconfiguration where the local machine lacks IPv4 or IPv6 connectivity so resolution skips that family.","solutions":["Make both addresses the same family (both IPv4 or both IPv6 literals, or both hostnames that resolve to the same family)","Pass family=socket.AF_INET (or AF_INET6) explicitly to force consistent resolution of both sides","Verify with socket.getaddrinfo() what each side actually resolves to in this environment"],"exampleFix":"# before\nawait loop.create_datagram_endpoint(factory, local_addr=('127.0.0.1', 0), remote_addr=('::1', 9999))\n\n# after\nawait loop.create_datagram_endpoint(factory, local_addr=('127.0.0.1', 0), remote_addr=('127.0.0.1', 9999))","handlingStrategy":"validation","validationCode":"async def families_agree(loop, local, remote) -> bool:\n    lf = {(i[0], i[2]) for i in await loop.getaddrinfo(*local, type=socket.SOCK_DGRAM)}\n    rf = {(i[0], i[2]) for i in await loop.getaddrinfo(*remote, type=socket.SOCK_DGRAM)}\n    return bool(lf & rf)\nassert await families_agree(loop, local_addr, remote_addr)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use same-family literals for loopback pairs (127.0.0.1/127.0.0.1, not ::1)","When one side is dynamic, pass family= to force both resolutions onto one family"],"tags":["asyncio","udp","address-family","ipv6"],"backgroundTag":null,"analyzedSha":"bc6749cc3b5ae4a5e88a6cc2d5b3bebbe354eae6","analyzedAt":"2026-08-14T22:01:13.976Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}