Apache won't respond to "localhost" or "127.0.0.1"

mattimpact

Registered
I have an OS X machine that is not connected to a network or the internet that I use for testing and development. According to the System Prefs, Web Sharing is active. When I open Internet Explorer and try http://localhost/ or http://127.0.0.1/ I get a message saying "Server not Found". I have looked at other forums (mainly the apple.com forums) and have found other people with similar problems, but no one has any answers.

I have checked the httpd.conf file for any weirdness, and there is nothing. I have another computer that is connected to a network and the internet, and I pulled it's network cable and tried accessing localhost, and it served up fine. Both machines are using the same version of OS X, and they are both running the default httpd.conf files.

Does anyone have any ideas? I am stumped. I appreciate any help that anyone might have to offer me in this problem.
 
what do you see with the network uytility port scan? it should show that port 80 is open

what happens if you telnet localhost 80 at the command line? you should connect to apache that way.

i m just trying to see whether it is your client that is the probelm
 
http://localhost/~username aliases ~/sites/
http://localhost/ aliases /Library/WebServer/Documents/

HTH
 
And if you check your Sharing tab in the System Preferences you probably won't be seeing an IP address at the bottom where it sais IP Address: ...

Now, I had this when I set the network preferences in the Network tab for the en0 interface (i.e. built in ethernet card) to be 127.0.0.1/255.0.0.0 ... this is because it conflicts with the lo0 interface (the loopback adapter) ...

So, the solution is to set your network preferences to something else (just leave it as DHCP is probably easiest).

The other problem I had, is that IE is a bit crap. Try using OmniWeb/NS6/anything else ... this is because IE gets its nickers in a twist when it can't access services via the en0 interface sometimes. The scenarios which lead to this are too numerous to list here. But see if the first tip helps you - and if not, then try a different browser (in conjunction with the first tip)

Note that the phenomenon described above also effects NFS. If you are running an NFS server (I think OS X does by default) and you switch your en0 to be 127.0.0.1, then the server will die and have to be manually restarted (well, that is to say, that was the case on my machine when I was running ... erm ... 10.1.2 I think - don't know if 10.1.4 has fixed this? Not going to try, either).

Anyhowz, hope that's of some help :)

C
 
Everyone has been a great help. I discovered that there was no open port 80 on my machine, even though Apache's congfig file says that is the port to use. I poked around the httpd manual pages, and found out that any port less than 127 (or some number around there) will not be opened unless first opened by the root acount. I tried logging in as root and starting Apache to "open" port 80, but that did nothing for me.

I finally came up with a workaround.... I changed the Apache config to use port 8080 instead of 80. Now the only annoying thing is that I have to append the port number to the URL.

So the problem with my computer is that it doesn't recognize double-digit ports. Anyone have any advice on this one? Everyone's suggestions above helped me a great deal in getting this far. Thanks!!!!!
 
Is your computer connected to the network?

In other words, do you have a physical connection between your network card and the internet?

If you do not, you will probably NOT see port 80 as open when you port scan.

If Apache IS working correctly you should get a page with http://127.0.0.1 or http://localhost. This will be the default Apache page served. When you add your ~username, you will get your default homepage stored in your Sites menu.

Hope some of this helps.:)
SA
 
Hi folks,
I was reading this thread, and I was wondering how I could change the default page served by Apache in OS X client. The idea is, I'd like to have somebody point to my computer's hostname in their web browser and not need to enter the "/~username" afterwards. I have my site in my home directory in the sites folder, and it works fine from there. How can I tell Apache to make this the default? Or is there somewhere I should move my files to other than my home directory? If I get OS X server, will it be any easier to define a default homepage? I'm practicing on OS X client now, but will be serving some pages on an OS X Server machine soon hopefully.

From a man of many questions,
Matthew
 
Something related has been happening to me when trying to serve pages to windows computers (XP Professional). I have a LAN using a crossover UTP between my Ti and my Desktop PC. When I type in IE (XP) http://my.mac.ip.address/ I got an error message of page not found. But, when I append the index.html.XX where XX is the code of the locale (i.e. ES por spanish) I can succesfully load the site home page. This does not happen with the user sites (~login). I also have a lot of problems with the 127.0.0.1 and the localhost thing, but I solve this problems by not using IE or by dissabling the network connection.

hope this helps.
 
SuperMatt-

The default web serving directory is /Library/WebServer/Documents/. Files put in this location can be browsed by going to http://127.0.0.1/

Note that this is not the Library folder that exists in your home directory, this is the root level Library folder.

You can also go to /private/etc/httpd/ and using "sudo", edit the httpd.conf file. I am not sure exactly where within that file you make the changes, but somewhere in that file is a place to set what the home directory is.

I hope this helps!
 
Back
Top