Serve: UnhandledPromiseRejectionWarning: Error: getaddrinfo ENOTFOUND <my hostname>

Created on 21 Jun 2018  ·  8Comments  ·  Source: vercel/serve

~~~bash
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
~~~

Most helpful comment

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:

└── 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

All 8 comments

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.

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.

same here

+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.

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

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.

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:

└── 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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Timer picture Timer  ·  5Comments

ghost picture ghost  ·  7Comments

ajchambeaud picture ajchambeaud  ·  4Comments

malinda1986 picture malinda1986  ·  6Comments

Olexiy665 picture Olexiy665  ·  3Comments