I had the same problem on a brand new MacBook Pro with OSX 10.13.6 and I found the solution in this posting:
You have to edit the file /etc/hosts . In my case, it was empty and i had to add these two lines:
127.0.0.1 localhost
255.255.255.255 broadcasthost
That’s it, works perfectly now!