I have been working with a node.js project for a few weeks and it has been working great. Usually, I use npm start to run my app and view it in a browser on loc
Came from Google here with a solution for High Sierra.
Something changed in the networking setup of macos and some apps (including ping) cannot resolve localhost.
Editing /etc/hosts seems like a fix:
cmd: sudo nano /etc/hosts/
content 127.0.0.1 localhost
Or simply (if you're sure your /etc/hosts is empty)
sudo echo '127.0.0.1 localhost' > /etc/hosts