Okay, I am a beginner with all this, so don't expect me know much. Let me know if this is the wrong place to ask this. What tags should I have used? THANKS a lot for your time.


I have a CGI script saved in /Library/WebServer/CGI-Executables.

I used to be able to run the script using the URL: http://localhost/cgi-bin/filename,


But now, Safari can't connect to the server?! Once or twice it begins to load then stays for a long time and eventually the same error comes up.

What could the problem be?

Extra Q's

I found my apache2 folder in /private/log/apache2 should this be moved?

Can I somehow run this script on something else without a server? Terminal works, but it is too hard to read.

  • is localhost up, is a server running ? That should be the first step. – phwd Jun 17 '11 at 18:06
  • Okay, sorry, but how to I check that? – Jon Jun 17 '11 at 18:11
  • @Jon The same way you checked for the script, type it into Safari http://localhost/ – phwd Jun 17 '11 at 18:24
  • Oh, ya, I've tried that before. NO same error. – Jon Jun 17 '11 at 18:32
  • Do this in a terminal: "ps -eaf | grep httpd"; if you get anything more than the "grep" line, things are running (but may need restarted). Otherwise Apache isn't running at all. (I've had occasions on other platforms where Apache will be running with httpd processes, but not respond to requests, so it is worth a check to see if there are processes running.) – Kerri Shotts Jun 17 '11 at 18:49

It seems like you are using Mac's built-in server and maybe somewhere along the line, web sharing was disabled.

Go to your System Preferences and enable Web Sharing.

To be sure httpd has started do what @Kerri mentioned in the comments

ps -eaf | grep httpd

which will display all processes that contain httpd as well as the Process ID

if you only get something like the following

501 22299 22030   0   0:00.00 ttys001    0:00.00 grep httpd

grep is the only process running referencing httpd

At this point try stopping and restarting the server manually

sudo httpd -k stop  
sudo httpd -k restart

Look also into the Console.app log and filter to see what information you can get from there.

If it is enabled you should get the following on pointing to localhost within a browser

It works!

So far so good, the server is running.

Now to navigate to the cgi-bin folder, if you used the scripts before then it should be mapped already in your configuration.

You could get


You don't have permission to access /cgi-bin/ on this server.

or an Internal Server Error if you went straight to the script

and you can chmod 755 the script and that should give you the correct permission to run it.

You can also check the access and error logs to see what's up


/var is the symbolic link to private/var

| improve this answer | |
  • Unfortunately, I've restarted the Web Sharing many times but it still doesn't work. I've run them before (after changing the permissions) but still nothing... Thanks though. Seems like the problem is deeper than I thought – Jon Jun 17 '11 at 18:57
  • @Jon what does it say in your logs? Check /var/log/apache2/error_log after you try and view the web page. – ghoppe Jun 18 '11 at 0:28
  • @ghoppe see apple.stackexchange.com/questions/16116/… – phwd Jun 18 '11 at 0:40

Run the following to see any other non-obvious errors. I did all the above and have had this Mac (without rebuilding -just upgrading and upgrading etc.) pre2004 - just kept upgrading - so there was quite a history on this mac. There were some skeletons in the closet. I JUST upgraded to Mountain Lion when the lid came off my web server.

Run this - look for errors on the output line.

sudo httpd -E /private/var/log/apache2

I had a module installed (SVN – but that is merely a detail) and it was loaded in the other category at the end of the httpd.conf file.

Here is the output of the command line – it pointed to the issue:

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

I renamed the svn.conf file to svn.deletedconffile and apache started right up. I also had to chmod to 755 all my Sites files – not 644 which is suggested on some sites.

| improve this answer | |

if you created a username.conf file in mountain lion delete it. After doing so restart apache and all should be well :)

| improve this answer | |
  • 2
    How should this help in accessing localhost? The user.conf files are only needed to access localhost/~user – nohillside Dec 30 '12 at 11:53

You must log in to answer this question.

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