Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnhandledPromiseRejectionWarning: Error: getaddrinfo ENOTFOUND <my hostname> #437

Closed
wolverian opened this issue Jun 21, 2018 · 8 comments · Fixed by #439
Closed

UnhandledPromiseRejectionWarning: Error: getaddrinfo ENOTFOUND <my hostname> #437

wolverian opened this issue Jun 21, 2018 · 8 comments · Fixed by #439

Comments

@wolverian
Copy link

wolverian commented Jun 21, 2018

src% mkdir tmp
src% cd tmp
tmp% echo "Hello, world!" > index.html
tmp% serve
(node:39744) UnhandledPromiseRejectionWarning: Error: getaddrinfo ENOTFOUND flower
    at errnoException (dns.js:50:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)
(node:39744) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:39744) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
^C
INFO: Gracefully shutting down. Please wait...
tmp% hostname
flower
tmp% nslookup `hostname`
Server:		10.245.22.6
Address:	10.245.22.6#53

** server can't find flower: NXDOMAIN
tmp% serve --version
9.1.0
@RafalWilinski
Copy link

RafalWilinski commented Jun 21, 2018

I'm also experiencing this issue. Using node v8.11.1 and serve 9.1.0. 9.0.0 also does not work for me. Downgrading to 8.0.0 resolved the issue.

@kazzkiq
Copy link

kazzkiq commented Jun 21, 2018

Yep, npm install serve@8 fixes the issue for now.

Also noticed that in the course of just a few weeks the version of this package jumped from 6.x to 9.x. Those are three major versions with the last one apparently broke.

While there is nothing wrong with releases coming this fast, it kinda raises curiosity about what exactly changed in the last weeks that made the need to increment so many versions.

@luisrudge
Copy link

same here

@karbica
Copy link

karbica commented Jun 25, 2018

+1

{ npm: '5.6.0',
  ares: '1.10.1-DEV',
  cldr: '32.0',
  http_parser: '2.8.0',
  icu: '60.1',
  modules: '57',
  napi: '3',
  nghttp2: '1.29.0',
  node: '8.11.2',
  openssl: '1.0.2o',
  tz: '2017c',
  unicode: '10.0',
  uv: '1.19.1',
  v8: '6.2.414.54',
  zlib: '1.2.11' }

@kazzkiq I too wondered the same thing. I checked my global modules for what's outdated and saw that jump. Strange.

@0xjjpa
Copy link

0xjjpa commented Jun 27, 2018

Same here, had to downgrade to serve@8 to get it working. Got the warning about 9.1.0 though.

@ryanhamley
Copy link

The issue is this line but the unhandled promise is masking an underlying issue where dns.lookup(os.hostname()) is failing, at least on my local machine.

I was able to fix the errors (again, at least on my local machine) by replacing line 176 with this:

const hostname = address === 'localhost' ? address : os.hostname();
const {address: ip} = await lookup(hostname)
.catch((err) => {
    console.error(error(`Not able to complete DNS lookup for ${hostname}: ${err.message}`));
    process.exit(1);
});

I'm not super familiar with this library or with what os.hostname() is supposed to be so I'm open to suggestions on whether or not this is an acceptable generalized solution.

@leo leo closed this as completed in #439 Jul 2, 2018
leo pushed a commit that referenced this issue Jul 2, 2018
When lookup fails, it throws an exception, that prevent other code from being executed

fixes #437
@saadq
Copy link

saadq commented Sep 28, 2018

I'm getting this issue in v10.0.2 as well. I just have a simple example directory that just has an index.html file in it:

example
└── index.html

When I run serve . the server works fine, but I get the following output:

ERROR: DNS lookup failed: getaddrinfo ENOTFOUND squadri

screen shot 2018-09-28 at 3 53 21 pm

@j0nd0n7
Copy link

j0nd0n7 commented Nov 14, 2018

Same issue with node v10.13.0 and serve 10.1.1.
Any progress on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants