Why is there a difference between using localhost and 127.0.0.1 in browser adress bar?
Posted by: Regin (---.static.spirit.net.au)
Date: January 22, 2013 11:52PM

I tried to access my sites using localhost, but got a 403 error. Yesterday I think it worked fine, did not change anything in between. Looked around on the forum, found that I could try with 127.0.0.1 instead of localhost. It worked, but now I need to understand why...?

Thanks you.
Regin

Options: ReplyQuote
Re: Why is there a difference between using localhost and 127.0.0.1 in browser adress bar?
Posted by: RiggsFolly (---.as13285.net)
Date: January 23, 2013 04:56PM

The reason is that your HOSTS file probably has 2 entries for the localhost domain name or maybe no entries for localhost.

Localhost is just an arbitrary domain name its not hard coded into the OS.
There is a file called HOSTS - c:\windows\stsrem32\drivers\etc\hosts

When windows starts up the network subsystem read this file ( it works like a local DNS ) and makes associations between domain names and IP Address's


It should have

127.0.0.1 localhost

on some recent win os's it also has

::1 localhost


127.0.0.1 is a IPV4 address
::1 is a IPV6 address

Wamp delivers apache expecting Windows to only know about an IPV4 network but newer versions know about IPV6 networks as well - eventually we will all move to IPV6 but the process is slow and microsoft is just trying to be ready when that happens.


The simplest solution I find is to remove the knowlede of the IPV6 network from the equasion as follows.


1. remove the ::1 line from your HOSTS file
2. amend the apache config so it will not listen on the IPV6 network
edit httpd.conf ( using the wampmanager menus wampmaneger -> Apache -> httpd.conf )
change the line 'Listen 80' to 'Listen 0.0.0.0:80'
This tells apache to only listen on the IPV4 network

Reboot

or

do this from the command line
>net stop "DNS Client"
>net start "DNS Client"
and then wampmanager icon -> restart all services

And try again to use the localhost domain name.

Options: ReplyQuote


Sorry, only registered users may post in this forum.