El Capitan Safari Can't open localhost but 127.0.0.1 works
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