GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: Error: getaddrinfo ENOTFOUND localhost · Issue #44003 · nodejs/node

test: Error: getaddrinfo ENOTFOUND localhost #44003

New issue
Copy link
New issue
Copy link
Closed
#44083
Closed
test: Error: getaddrinfo ENOTFOUND localhost#44003
#44083
Copy link

Description

@AdamMajer
AdamMajer
opened on Jul 26, 2022
Issue body actions

Version

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.

Activity

  1. kvakil commented on Jul 27, 2022

    @kvakil
    kvakil
    on Jul 27, 2022
    Contributor
    More actions

    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]) = 66
  2. theanarkh commented on Jul 27, 2022

    @theanarkh
    theanarkh
    on Jul 27, 2022
    Contributor
    More actions

    I get this error sometimes on my pc, but not always.

  3. bnoordhuis commented on Jul 27, 2022

    @bnoordhuis
    bnoordhuis
    on Jul 27, 2022
    Member
    More actions

    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
  4. AdamMajer commented on Jul 27, 2022

    @AdamMajer
    AdamMajer
    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.

    Reacted by Eastboat
  5. bnoordhuis commented on Jul 28, 2022

    @bnoordhuis
    bnoordhuis
    on Jul 28, 2022
    Member
    More actions

    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.

  6. AdamMajer commented on Jul 28, 2022

    @AdamMajer
    AdamMajer
    on Jul 28, 2022
    ContributorAuthor
    More actions

    So, the bisect ended up on 70b516e which is #43054 . Looking at the pull request, it kind of makes sense this is the one as the tests in question are explicitly skipped on some platforms.

    https://github.com/nodejs/node/pull/43054/files#diff-5ba63fa1f910a3ec440b5174993719278ddca69569c0159e2c782173af190602

    The test is reproducible every time on openSUSE:Tumbleweed build VM. I can't reproduce it outside of it on a workstation, but in the VM with no networking connections and only a hosts file to resolve localhost to ipv6 and ipv4, it reproduces every time.

    I will try to look more closely what is actually failing here.

  7. AdamMajer commented on Jul 28, 2022

    @AdamMajer
    AdamMajer
    on Jul 28, 2022
    ContributorAuthor
    More actions

    This was introduced in 18.4.0. I mistyped earlier the versions. 18.2.0 still passed

  8. kapouer commented on Aug 1, 2022

    @kapouer
    kapouer
    on Aug 1, 2022
    Contributor
    More actions

    Is there no network interface at all, no loopback ?

  9. AdamMajer commented on Aug 1, 2022

    @AdamMajer
    AdamMajer
    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
  10. AdamMajer
    added a commit that references this issue on Aug 1, 2022

    net, dns: socket should handle its output as input

    a6c0fd2
  11. nodejs-github-bot
    closed this as completedin #44083on Aug 3, 2022
  12. nodejs-github-bot
    added a commit that references this issue on Aug 3, 2022

    net, dns: socket should handle its output as input

    ddd9c70
  13. danielleadams
    added a commit that references this issue on Aug 16, 2022

    net, dns: socket should handle its output as input

    e6a47e8
  14. ruyadorno
    added a commit that references this issue on Aug 23, 2022

    net, dns: socket should handle its output as input

    c3d8756
  15. juanarbol
    added 2 commits that reference this issue on Oct 3, 2022

    net, dns: socket should handle its output as input

    c3a89ff

    net, dns: socket should handle its output as input

    9bd3fae
  16. Daniel-quintero1 commented on Oct 3, 2023

    @Daniel-quintero1
    Daniel-quintero1
    on Oct 3, 2023
    More actions

    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
  17. kyungseopk1m commented on Oct 16, 2023

    @kyungseopk1m
    kyungseopk1m
    on Oct 16, 2023
    More actions

    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
  18. haojieZzz commented on Aug 2, 2024

    @haojieZzz
    haojieZzz
    on Aug 2, 2024
    More actions

    I add the line in my hosts file and it worked;

    127.0.0.1 localhost

    Reacted by Thore Strassburg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.