DocPad HOSTNAME issue

Bates, Simon sbates at ocadu.ca
Mon Sep 12 18:57:36 UTC 2016


On Friday, I hit a problem running DocPad on Linux that I'd like to share in case others hit the same issue.

I was running DocPad for infusion-docs but the issue I hit is independent of infusion-docs.

When running the DocPad built-in server, I was seeing this error message:

Error: getaddrinfo ENOTFOUND <hostname of my computer>
  at errnoException (dns.js:27:10)
  at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:78:26)

I was able to trace the problem to the following logic in DocPad:

getHostname: ->
    return @getConfig().hostname ? require('hostenv').HOSTNAME ? '0.0.0.0'

https://github.com/docpad/docpad/blob/fe3fbfface36a1c64330cdffaa4716edee776432/src/lib/docpad.coffee#L1774-L1775

Which I think (my CoffeeScript isn't super strong) means use hostname from the config if it's set, otherwise the value of the HOSTNAME environment variable, and if that's not set, then default to 0.0.0.0.

In my case, my Linux box sets HOSTNAME to my computer hostname but there is no DNS mapping for it. So, when DocPad tries to bind to that address, the DNS lookup fails and I get the error.

To work around this issue, I can use my shell's (bash) per-command environment overriding as in:

$ HOSTNAME=localhost npm run docpad

Simon


More information about the fluid-work mailing list