Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:    localhost 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 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

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

Localhost is always 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 to something other than "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 since I'd seen that mentioned in my searching. But I don't think it helped/worked. I used 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 – KCotreau Jul 21 '11 at 23:49
Found this: "fe80::1 is typically used as the "localhost" address--the IPv6 equivalent of" 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 is the IPv4 loopback/localhost address. – KCotreau Jul 22 '11 at 2:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .