GeezerVison is showing github.com — test: Error: getaddrinfo ENOTFOUND localhost · Issue #44003 · nodejs/node
test: Error: getaddrinfo ENOTFOUND localhost #44003DescriptionVersion
18.6.0
Platform
openSUSE Tumbleweed
Subsystem
No response
What steps will reproduce the bug?
Currently the failures are visible in the current build log,
https://build.opensuse.org/public/build/devel:languages:nodejs/openSUSE_Tumbleweed/x86_64/nodejs18/_log
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior?
No response
What do you see instead?
not ok 1995 parallel/test-net-socket-connect-without-cb
---
duration_ms: 0.506
severity: fail
exitcode: 1
stack: |-
node:events:491
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND localhost
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:111:26)
Emitted 'error' event on Socket instance at:
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'localhost'
}
Node.js v18.6.0
...
...
not ok 2000 parallel/test-net-socket-ready-without-cb
---
duration_ms: 0.507
severity: fail
exitcode: 1
stack: |-
node:events:491
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND localhost
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:111:26)
Emitted 'error' event on Socket instance at:
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'localhost'
}
Node.js v18.6.0
...
not ok 2591 parallel/test-tcp-wrap-listen
---
duration_ms: 0.818
severity: fail
exitcode: 1
stack: |-
(node:18408) internal/test/binding: These APIs are for internal testing only. Do not use them.
(Use `node18 --trace-warnings ...` to show where the warning was created)
node:events:491
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND localhost
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:111:26)
Emitted 'error' event on Socket instance at:
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'localhost'
}
Node.js v18.6.0
...
Additional information
> cat /etc/hosts
127.0.0.1 localhost
#
# hosts This file describes a number of hostname-to-address
# mappings for the TCP/IP subsystem. It is mostly
# used at boot time, when no name servers are running.
# On small systems, this file can be used instead of a
# "named" name server.
# Syntax:
#
# IP-Address Full-Qualified-Hostname Short-Hostname
#
127.0.0.1 localhost
# fallback hostname used by NetworkManager
127.0.0.1 localhost.localdomain
# special IPv6 addresses
::1 localhost ipv6-localhost ipv6-loopback
fe00::0 ipv6-localnet
ff00::0 ipv6-mcastprefix
ff02::1 ipv6-allnodes
ff02::2 ipv6-allrouters
ff02::3 ipv6-allhosts
and resolv.conf doesn't exist. All other test cases that use localhost are passing, as expected. Activitykvakil commented on Jul 27, 2022 curious what you see when doing strace. On Ubuntu I see the following:
$ strace -ff ./node test/parallel/test-tcp-wrap-listen.js |& grep localhost
[pid 4385] read(19, "127.0.0.1 localhost\n\n# The follo"..., 4096) = 221
[pid 4385] sendto(19, "\362*\1 \0\1\0\0\0\0\0\1\tlocalhost\3ec2\10inter"..., 51, MSG_NOSIGNAL, NULL, 0) = 51
[pid 4385] recvfrom(19, "\362*\201\203\0\1\0\0\0\0\0\1\tlocalhost\3ec2\10inter"..., 1024, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.53")}, [28 => 16]) = 51
[pid 4385] sendto(19, "Uk\1 \0\1\0\0\0\0\0\1\tlocalhost\0\0\34\0\1\0\0)\4\260"..., 38, MSG_NOSIGNAL, NULL, 0) = 38
[pid 4385] recvfrom(19, "Uk\205\240\0\1\0\1\0\0\0\1\tlocalhost\0\0\34\0\1\300\f\0\34\0"..., 1024, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.53")}, [28 => 16]) = 66theanarkh commented on Jul 27, 2022 I get this error sometimes on my pc, but not always. bnoordhuis commented on Jul 27, 2022 ENOTFOUND is a synthetic error that node fabricates when it doesn't get an answer back from getaddrinfo(3), it's not a real operating system-level error. Reasons include running out of file descriptors in libc (not visible to node), not getting back a response from the DNS server, etc. It's basically a catch-all. Reacted by rbakerch, Daniel Arthur Grabowski, Andrew C and Agustin Pomies AdamMajer commented on Jul 27, 2022 ContributorAuthor More actions In this case, there is no DNS server and it works with other tests...
strace shows nothing. This is only a problem since about 18.2.0 and not before and not in any other released line. And I only see it in a VM build environment and not in a chroot (at least it disappeared there) which is very strange.
I will try to bisect the issue. bnoordhuis commented on Jul 28, 2022 You mean v18.1.0 works? There are no changes between the two that seem like likely culprits. I'm interested to see what bisect turns up. AdamMajer commented on Jul 28, 2022 ContributorAuthor More actions AdamMajer commented on Jul 28, 2022 ContributorAuthor More actions This was introduced in 18.4.0. I mistyped earlier the versions. 18.2.0 still passed kapouer commented on Aug 1, 2022 Is there no network interface at all, no loopback ? AdamMajer commented on Aug 1, 2022 ContributorAuthor More actions So, I've learned something about debugging node over last few days :-) But I did find the problem.
> NODE_DEBUG=net ./node18 test/parallel/test-net-socket-ready-without-cb.js
NET 1834: setupListenHandle ::1 0 6 false undefined
NET 1834: setupListenHandle: create a handle
NET 1834: bind to ::1
{ address: '::1', family: 'IPv6', port: 32841 }
NET 1834: pipe false undefined
NET 1834: connect: find host localhost
NET 1834: connect: dns options { family: 'IPv6', hints: 32 }
The problem is that family is set to a string, which causes hints to be set to 32 which means AI_ADDRCONFIG and then address resolution fails.
On a network connected device, this passes.
Why? We can look at the manpage for getaddrinfo
If hints.ai_flags includes the AI_ADDRCONFIG flag, then IPv4 addresses are returned in the list pointed to by res only if the local system has at least one IPv4 address configured, and IPv6 addresses are returned only if the local system has at least one IPv6 address configured. The loopback address is not considered for this case as valid as a configured address. This flag is useful on, for example, IPv4-only systems, to ensure that getaddrinfo() does not return IPv6 socket addresses that would always fail in connect(2) or bind(2).
This is why these tests fail every time when you have a loopback interface as the only network interface active. They will pass if you have other network interfaces active. Reacted by Andreas Roussos Reacted by Daniel Arthur Grabowski Daniel-quintero1 commented on Oct 3, 2023 original: Error: getaddrinfo ENOTFOUND undefined
GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:118:26) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'undefined'
el error aca como podria solucionar? me arroja basicamente que no encuentra mi localhost. Reacted by Axtronau7 and Kang Afif kyungseopk1m commented on Oct 16, 2023 In my case, the same error occurred when I made a request to a server address other than localhost, but it turned out that there was no problem with me and the problem was with the server.
Additionally, requests intermittently repeated success and failure. Reacted by Daniel Quintero haojieZzz commented on Aug 2, 2024 I add the line in my hosts file and it worked;
127.0.0.1 localhost
Reacted by Thore Strassburg
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|