127.0.0.1 is accessible/working but localhost not accessible/ not working

apache, php, phpmyadmin, wamp, windows

Solution

Mine is Ubuntu 20.04 VM

I had this following line.

::1     localhost ip6-localhost ip6-loopback

I commented that line and added the following line.

::1     ip6-localhost ip6-loopback

Basically removed

::1     localhost

It now works.

The final look of the hosts file is as follows.

127.0.0.1       localhost
127.0.1.1       vagrant.vm      vagrant

# The following lines are desirable for IPv6 capable hosts
#::1     localhost ip6-localhost ip6-loopback
::1     ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.2.1 w1 w1

Problem

I am using wamp for few years and i upgraded to windows 8 few months before, my wamp working smoothly up to yesterday. But now it can't be accessed using localhost. but when i trying 127.0.0.1 instead it works smoothly. I changed ::1 localhost to 127.0.0.1 localhost in host file. which where the solution suggested for this problem in most websites. But unfortunately its not work for me. When i ping localhost its showing replay from ::1: time<1ms. And There is no software's using port 80 i already checked it. please help to solve this.

Original source