I was running into the same problem and after some trial and error discovered that my hosts
file customisation was causing the problem.
My localhost
DNS was overwritten and because of that a simple ping was failing:
$ ping http://localhost
# ping: cannot resolve http://localhost: Unknown host
Once I resolved the configuration of /private/etc/hosts
file, pinging localhost
successfully worked, and was no longer getting the error that you were seeing:
# Fatal error: getaddrinfo ENOTFOUND