Search code examples
apachewampserver

Wampserver did not work on localhost


I just installed Wampserver. after installing it, the icon color is green and say the server is online. then I tried localhost on my browser. it showed "the site can't be reach" but when I entered http://127.0.0.1/ it works and displays Wampserver homepage. Why it did not work when I entered "localhost"? it only can enter http://127.0.0.1/ . Is there something that I must change in the settings? when I tried to change the port be port 80, it showed "CLI stop working".


Solution

  • localhost does not exists automatically. Its actually a domain name you have to create on your PC. You do this by adding it to your HOSTS file.

    Edit the file C:\windows\system32\drivers\etc\hosts

    Add these lines to it

    localhost  127.0.0.1
    localhost ::1
    

    You also need the ::1 version as well as that is IPV6, and lots of browsers will attempt to use the IPV6 network in preference to the IPV4 (127.0.0.1)

    You will have to be an Administrator to edit this file as it is protected by windows.

    Or open your editor by right clicking on it, and selecting the "Run as Administrator" menu option.