Ubuntu 14.04(Trusty) uses glibc-2.19, which can't reliably resolve IP address under some circumstances.
Unluckily Node.js doesn't have an option like Java system property java.net.preferIPv4Stack=true
,
it resolves both IPv4 and IPv6 addresses by default, so here is this tiny magical module.
WARNING: you'd better upgrade your host OS or Docker base image, usage of this hack is not recommended.
Just include it in your package.json:
npm install --save dns4
And import it at the very beginning of your program:
require('dns4') // hijack functions of module dns
// require() other modules