El Capitan Safari Can't open localhost but 127.0.0.1 works 127.0.0.1   localhost
 255.255.255.255 broadcasthost
 ::1             localhost


This is my /etc/hosts configuration. I can use ip address 127.0.0.1 to open a loopback, but 'localhost' fails....
I have read these two posts:El Capitan Safari Can&#39;t open localhost
and 
El Capitan Safari Can&#39;t open localhost, but none of the cases fits my problem.

The error message I got from Safari is


  Safari can’t open the page “‎localhost” because the server unexpectedly dropped the connection. This sometimes occurs when the server is busy. Wait for a few minutes, and then try again.


I also tried the localhost on Chrome, it gave me similar message...
Is there something wrong with setting alias?
After reading this post 
https://stackoverflow.com/questions/20345132/127-0-0-1-is-working-but-localhost-not-working

I figured it out that I only need to comment out ::1  localhost
then everything works fine