Cannot access localhost through 127.0.1.1 or 127.0.0.1

I'm having problems with a local installation of Magento and apparently it's caused by using the localhost address.

Apparently it works using either 127.0.1.1 or 127.0.0.1

But I cannot access localhost with either of these addresses!! 127.0.1.1 times out and 127.0.0.1 simply cannot connect.

I've checked my hosts file and it reads:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost

Which appears to be correct? I even tried setting up my own address but that didn't work either.

Does anyone know what might be wrong??

Thanks

Intel iMac, Mac OS X (10.6.4)

Posted on Sep 4, 2010 11:09 AM

Reply
9 replies

Sep 4, 2010 12:35 PM in response to pealo86

pealo86, it looks as though there are a few leading number-signs missing from the comments of your /etc/hosts file.

If you open a Terminal window and run the command *openssl dgst -sha1 -c /etc/hosts*, is the output from that command


SHA1(/etc/hosts)= 51:6f:ee:54:30:1d:8f:ea:57:72:39:60:2a:cf:dd:3b:d0:62:e8:88


If so, then your /etc/hosts file is fine, and the copy of it in your post just lost a few leading number-signs between copying and pasting.

If the output is different, though, then you’ll want to edit it to make sure that there are leading number-signs on the second, fourth, and fifth lines (as were there originally).

I hadn’t heard of localhost ever being equated to 127.0.1.1; its traditional value is 127.0.0.1, as your /etc/hosts file shows.

From within the Terminal window, try the *ping -c 3 localhost* command; are the first lines of output something like


PING localhost (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.045 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.050 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.069 ms



(The times at the end of each line will vary.) If so, then localhost is perfectly accessible at 127.0.0.1.

Sep 4, 2010 1:51 PM in response to pealo86

Thanks very much for the help, I tried the first command and it gave me something completely different! Here's what it gave me:
7a:e2:ef:fa:52:fa:b6:a0:ae:1e:2d:2c:d9:c2:f4:11:d9:b1:b3:30

And here's what the second command gave me, doesn't look too good!
*ping: cannot resolve localhost: Unknown host*

What would you suggest I do next?

Thanks

Sep 4, 2010 2:13 PM in response to pealo86

pealo86, my suggestion for what to do next remains the same: edit /etc/hosts +to make sure that there are leading number-signs on the second, fourth, and fifth lines (as were there originally).+

Because the /etc/hosts file is owned by the root user, you’ll need to use an admin account to make changes to the file. (If you’re comfortably familiar with Unix commands, running *sudo vim /etc/hosts* from a non-admin account would work just as well as editing from an admin account.)

Once you’ve saved the edited /etc/hosts file, retry the ping command to make sure that localhost is accessible.

Sep 5, 2010 12:31 PM in response to pealo86

pealo86, I’ve had a look at the HTML that your initial post generated, and I think that the posting software here was responsible for changing the number-signs on those lines to a numbered list.

So that we can tell the exact contents of your /etc/hosts file, please do the following:

• open a Terminal window
• run *cd /tmp*
• run *uuencode -o hosts.uu /etc/hosts pealo86_hosts*

This will encode a copy of your /etc/hosts file into a file named hosts.uu in your /tmp directory. When the encoded file is decoded, the file that will be created will be named pealo86_hosts.

• run *cat hosts.uu*

This will display the contents of the hosts.uu file.

• In your reply to this post, type in two consecutive “
” lines (without the quotation marks), as Bob suggested; copy the output from the cat command (from the begin line to the end line, inclusive); and paste it between those two lines.
The encoding is necessary to preserve the spaces and tabs through the posting software here. The “
” lines will be needed to make sure that the encoded content isn’t altered by the posting software here.

Sep 7, 2010 11:29 AM in response to Baumkartoffel

Ahhh I see!

Here is the code output


M(R,*(R!(;W-T($1A=&%B87-E"B,*(R!L;V-A;&AO<W0@:7,@=7-E9"!T;R!C
M;VYF:6=U<F4@=&AE(&QO;W!B86-K(&EN=&5R9F%C90HC('=H96X@=&AE('-Y
M<W1E;2!I<R!B;V]T:6YG+B`@1&@;F]T(&-H86YG92!T:&ES(&5N=')Y+@HC
M(PHQ,C<N,"XP+C$)=W=W+FQO8V%L:&]S="YC;VT*,C4U+C(U-2XR-34N,C4U
M"6)R;V%D8V%S=&AO<W0*.CHQ("`@("`@("`@("`@(&QO8V%L:&]S="`*9F4X
3,#HZ,25L;S`);&]C86QH;W-T"@``
`
end

Sep 7, 2010 3:07 PM in response to pealo86

pealo86, the problem is on the 127.0.0.1 line:


127.0.0.1 www.localhost.com


That line was originally, and still should be


127.0.0.1 localhost


(The original /etc/hosts file has a tab character separating the IP address from the name, but the tab will probably be turned to spaces in the post.)

Try correcting this line, then retry the ping command that was given in a previous post.

Sep 8, 2010 12:21 AM in response to Baumkartoffel

Ohhh I see! Thanks.

I've corrected it now by changing www.localhost.com to localhost.

I've tried the ping command and everything looks okay (3 packets received, 0% packet loss).

However I still cannot access localhost by visiting '127.0.0.1', is this normal behaviour?

I have a feeling I changed localhost to www.localhost.com a few months ago due to the problems I was having with Magento but I can't remember if I was ever able to access localhost by typing this in.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Cannot access localhost through 127.0.1.1 or 127.0.0.1

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.