Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've successfully used PHP/Apache/MySQL on my iMac several times in the past few months/years. However, I started using a new PHP book and moved things around a bit (obviously without knowing what I thought I was doing!) I managed to get localhost working about a week ago. I had to stop work on this project until late today. Once again, using a saved bookmark for phpMySql today, I got the infamous "cannot connect to localhost." message.

To make this somewhat shorter, I can now access localhost again. Whew! Here's my hosts file:

10.0.1.2    localhost
255.255.255.255 broadcasthost
::1             localhost
# fe80::1%lo0   localhost

Firstly, I have no idea what that last, commented out line is for, but I'll search the net after posting this.

Secondly, the 10.0.1.2 used to appear in the "Web Sharing" Pref Panel. Now it has my computerName/~username.

Finally, although localhost is working (and I changed the bookmark for it), apachectl -t shows this response:

httpd: Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName

I thought from reading that this indicated the use of IPv6 but turning that OFF in Network PP doesn't seem to make any difference in the response from Apache.

As you can see, I know just enough to be dangerous, fortunately only to myself, I hope!

share|improve this question

1 Answer 1

At the very least, your hosts file is incorrect, and can cause problems.

Localhost is always 127.0.0.1. That is a special IP address used only for that. It is the address that the network adapter uses to communicate internally.

You should change the DNS name for 10.0.1.2 to something other than "localhost".

http://en.wikipedia.org/wiki/Localhost

share|improve this answer
    
Another way to look at localhost is that it is a generic way of saying "this computer" when you put it in the URL box. –  KCotreau Jul 21 '11 at 23:28
    
I'm pretty sure I tried 127.0.0.1 since I'd seen that mentioned in my searching. But I don't think it helped/worked. I used 10.0.1.2 because that is what I see in my Network Pref Panel as the IP for this machine. However, I agree that it can change depending on when it starts up compared to others on my LAN. OTOH, it is the only machine directly connected to the cable router (others are via WiFi). Without restarting the machine, I'm seeing the same message in Terminal (using ::1 for ServerName) but I can still access phpMyAdmin. A thunderstorm is approaching...I'll shut down. Thanks! –  Jim Chaffin Jul 21 '11 at 23:45
    
You can use any DNS name for the IP of your computer, but localhost IS 127.0.0.1. –  KCotreau Jul 21 '11 at 23:49
    
Found this: "fe80::1 is typically used as the "localhost" address--the IPv6 equivalent of 127.0.0.1." at this SU thread from @eater. (still trying to learn this Markdown formatting, sorry) Another confirmation of your "localhost IS 127..." ;-) Thanks –  Jim Chaffin Jul 22 '11 at 2:06
    
Right, and 127.0.0.1 is the IPv4 loopback/localhost address. –  KCotreau Jul 22 '11 at 2:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.