Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

localhost access not working under Leopard

When I attempt to set my browser to a URL like:

http://localhost/~AllenW/UnityByAW/index.html

I get a message telling me, "Forbidden: you do not have access to blah-blah on this server."

Yet, if I boot back into Tiger and try the exact same thing, it works fine. Same user (AllenW) in both cases. I have no other trouble with file permissions.

Any suggestions, anyone?

Macbook (1st gen) 2GB RAM, Mac OS X (10.5)

Posted on Nov 4, 2007 4:49 PM

Reply
21 replies

Nov 15, 2007 1:42 PM in response to Allen Watson1

I am also having trouble with web sharing in Leopard. I've turned it on under system preferences and can't even access the server. It appears to be running but regardless of whether I type in the IP address, use 127.0.0.1 or use localhost it comes up with the following message.

+Safari can’t connect to the server.+
+Safari can’t open the page “ http://localhost/~YourUserName/” because it could not connect to the server “localhost”.+

I tried what you suggested and cannot view the file either.

Does anyone have any idea what the issue is or how to fix it.

Nov 20, 2007 5:06 PM in response to wHaTEvEr-

Leopard uses Apache 2. Tiger used Apache 1.3.

Your config works on tiger because the appropriate user.conf files are in the Apache 1.3 path. They are not moved during an upgrade.

Under this path: /etc/apache2/users

I have a file for each user:

user1.conf
user2.conf

Where user1.conf contains:

<Directory "/Users/ user1/Sites/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

I hope that helps.

I also updated my php using the latest entropy package... as I had the Apache 1.3 version installed before. See http://www.entropy.ch/software/macosx/php/

Nov 20, 2007 5:13 PM in response to Allen Watson1

redundant threads.... BAH



You need to have a file named <your_username>.conf in /private/etc/Apache2/users/ for Apache to work properly. Probably you don't have it there or you wouldn't be here :P...
The file might exist in /private/etc/Apache2/users/<your username>.conf and if it does, just copy it to the first folder.
If it doesn't exist, you may create it with the following contents:

<Directory "/Users/<your username>/Sites/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

Don't forget to change "<your username>"...

Now I belive that you just need to restart Apache on the Sharing Pref. Pane and you're good to go...

Nov 20, 2007 8:57 PM in response to Allen Watson1

I've tried all of the suggestions that have been posted thus far and still no luck. I've restarted the web sharing as instructed after making the changes and I still get the response:
"Safari can’t connect to the server.
Safari can’t open the page “ http://localhost/” because it could not connect to the server “localhost”."

Maybe it's something simple, maybe it's not, but it sure has me stumped.

Has anyone else who has had this problem had success with the posted solutions?

Nov 21, 2007 12:21 PM in response to wHaTEvEr-

You suggest copying a file "to the first folder", but the two paths you give are identical. Huh?

It looks to me as if /private/etc/apache2/users and /etc/Apache2/users point to the same directory; when I cd to them and ls, I see the same three files including the "AllenW.conf" file I created as instructed here. I am still getting the message in Safari, 'Safari can’t open the page “ http://localhost/~AllenW/” because it could not connect to the server “localhost”.'

I've also been to http://foundationphp.com/tutorials/php_leopard.php and have followed those instructions, to no avail.

Nov 21, 2007 10:08 PM in response to matt kelly1

I took the suggestion to download and install XAMPP. And it worked. The only "problem" was that it expects to find websites in a different location. Rather than "Sites" the websites are expected to be in /Applications/xampp/htdocs/. Once I moved my site folder there, everything works. There is some helpful documentation at http://www.apachefriends.org/en/xampp-macosx.html#873.

Jan 4, 2008 8:26 PM in response to RetiredToWrite

This one had me losing some hair for a while, too, but I got it running again, after of course doing everything recommended here -- the problem seemed to be that apache was looking for its log directory, and there wasn't one. (I figured this out while trying to read the ErrorLog, which should have been the first thing I did, but live and learn.)

So, in the finder, Go > Go To Folder, and type /private/var/log.

There should be a folder called apache2 in that directory. If there's not, that's a problem (although I wouldn't dare assume it's the only one).

To make sure, check out the system log by double-clicking on the file in the directory called system.log. When I did that with the web server (supposedly) running, I saw this:

Jan 4 20:42:32 Hatter org.apache.httpd[1028]: (2)No such file or directory: httpd: could not open error log file /private/var/log/apache2/error_log.
Jan 4 20:42:32 Hatter org.apache.httpd[1028]: Unable to open logs
Jan 4 20:42:32 Hatter com.apple.launchd[1] (org.apache.httpd[1028]): Exited with exit code: 1
Jan 4 20:42:32 Hatter com.apple.launchd[1] (org.apache.httpd): Throttling respawn: Will start in 10 seconds
Jan 4 20:42:42 Hatter org.apache.httpd[1029]: (2)No such file or directory: httpd: could not open error log file /private/var/log/apache2/error_log.
Jan 4 20:42:42 Hatter org.apache.httpd[1029]: Unable to open logs
Jan 4 20:42:42 Hatter com.apple.launchd[1] (org.apache.httpd[1029]): Exited with exit code: 1
Jan 4 20:42:42 Hatter com.apple.launchd[1] (org.apache.httpd): Throttling respawn: Will start in 10 seconds

over and over, every ten seconds, for as long as the web server was active.

To fix that, just create that directory. Turn off the webserver, then from terminal:

mkdirhier /private/var/log/apache2/

and restart the webserver.

Feb 17, 2008 12:49 PM in response to jewhanso

Same problem for me - I also tried all above suggestions (re. conf files and paths). As jewhanso says, I (also) get the message: Safari can’t open the page "http://localhost/..." because it could not connect to the server "localhost".

Leopard seems to lack a way of designating the local loopback address. Maybe this is IP v.6-related?

Does anybody know how to properly specify the local loopback address in IP V.6? Maybe that will work. I tried using both http://localhost/~mydir/index.php and http://127.0.0.1/~mydir/index.php. They work fine on my Tiger-based MacBook but not under Leopard.

Interestingly - in Leopard, the Apple > System Preferences > Sharing checkbox reads "Web Sharing" (using an external network address). In Tiger this is "PERSONAL Web Sharing" (using the local loopback address). The editing text-boxes disallow the use of 'localhost' or '127.0.0.1'.

There's an interesting error message in the apache2/error_log that reads "[Sat Feb 16 20:05:00 2008] [error] [client ::1] File does not exist: /Users/<mydir>/Sites/sites. Note the '... [client::1] ...' syntax. I don't know for sure but I am guessing this is an IP v.6 syntax - replacing the older syntax for the loopback address. I.e. localhost = IP address 127.0.0.1".

Looks like an Apple "faux pas" to me. :-/

Feb 23, 2008 10:43 AM in response to Terry Mahoney

I FOUND the source of MY problem (localhost access not working under leopard - 10.5.2). I had unintentionally corrupted the httpd.conf file in /private/etc/apache2 when I edited it using TextWrangler. Not realizing what I was doing, I had used TextWrangler >Text > Add/Remove line numbers instead of TextWrangler > View > Text Display > Show Line Numbers, which prefixed/prepended the text of the line numbers to the lines in the saved file. :-/

The result was that Apache had not processed the httpd.conf file. I discovered this by testing Apache from Terminal using the 'sudo apachectl -t' comand. The resulting error message indicated a "syntax error on line 1" and displayed the line as "1 #" - making the problem obvious.

Fixing this (after having followed the directions in http://foundationphp.com/tutorials/php_leopard.php) and then stopping and restarting Apache left me with Apple's stock Apache 2 running and PHP 5 testing out perfectly.

Mar 2, 2008 7:46 PM in response to Terry Mahoney

Awesome! This lead me to the fix for MY problem as well ("cannot connect to server" error).

I ran "sudo apachectl -t" in the terminal and got this:

httpd: Syntax error on line 116 of /private/etc/apache2/httpd.conf: Cannot load /usr/libexec/apache2/libphp4.so into server: dlopen(/usr/libexec/apache2/libphp4.so, 10): image not found

Makes sense...there is no PHP4. I went to /private/etc/apache2/httpd.conf, commented line 116 (and subsequently un-commented line 114 for PHP5), restarted Web Sharing and Boom! It works!

Thanks Terry, for the clue!

Mar 3, 2008 1:08 PM in response to So Glitchy

Thanks Glichy.

I followed all of the other advice, and this was the last one that I found. It must not be as common as some of the other issues.

You did leave out one small thing that confuses noobs like me though. The all important sudo command.

So the Terminal entry should look like this:

sudo mkdirhier /private/var/log/apache2/

Then enter your password and restart the webserver.

localhost access not working under Leopard

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