diff --git a/connectd/connectd.c b/connectd/connectd.c index 54ac08918db0..f72a1931cc17 100644 --- a/connectd/connectd.c +++ b/connectd/connectd.c @@ -1134,7 +1134,14 @@ static void try_connect_one_addr(struct connecting *connect) hints.ai_socktype = SOCK_STREAM; hints.ai_family = AF_UNSPEC; hints.ai_protocol = 0; + /* AI_ADDRCONFIG speeds up connects on single-stack hosts by + * pruning unreachable address families. Skip on macOS/BSD + * where it opens temporary probe sockets that confuse our + * fd-leak checker. */ +#ifndef __APPLE__ hints.ai_flags = AI_ADDRCONFIG; +#endif + gai_err = getaddrinfo((char *)addr->u.wireaddr.wireaddr.addr, tal_fmt(tmpctx, "%d", addr->u.wireaddr.wireaddr.port), diff --git a/tests/test_gossip.py b/tests/test_gossip.py index 326a4391af40..a431fd2f8e4c 100644 --- a/tests/test_gossip.py +++ b/tests/test_gossip.py @@ -202,6 +202,13 @@ def test_announce_and_connect_via_dns(node_factory, bitcoind): - --disable-dns is needed so the first node does not announce 127.0.0.1 itself. - 'dev-allow-localhost' must not be set, so it does not resolve localhost anyway. """ + # localhost.localdomain is not present in /etc/hosts on macOS by default. + # See https://github.com/ElementsProject/lightning/issues/9012 + try: + socket.getaddrinfo('localhost.localdomain', 12345, 0, socket.SOCK_STREAM) + except socket.gaierror: + pytest.skip("localhost.localdomain not resolvable; add '127.0.0.1 localhost.localdomain' to /etc/hosts") + opts1 = {'disable-dns': None, 'announce-addr': ['dns:localhost.localdomain:12345'], # announce dns 'bind-addr': ['127.0.0.1:12345', '[::1]:12345']} # and bind local IPs