Edit /etc/hosts files and add this line at top:
127.0.0.1 localhost
Save the file and try again, if that doesn’t work, edit again the /etc/hosts file and comment this line:
::1 localhost ip6-localhost ip6-loopback
So it will look like this:
#::1 localhost ip6-localhost ip6-loopback