I am trying to set up an Apache vhost on Mavericks, something that I was able to do easily on 10.6.8. I am using the default Apache that is preinstalled on a fresh install of OS X 10.9.2

$ sudo apachectl start
org.apache.httpd: Already loaded

$ ping localhost
PING localhost ( 56 data bytes
64 bytes from icmp_seq=0 ttl=64 time=0.053 ms

But when I navigate to either http://localhost or on any of my 3 browsers, I'm told I can't connect, instead of seeing Apache's "It Works!" message. (On Chrome I see "Oops! Google Chrome could not connect to localhost")

I also tried adding a vhost:

  1. Uncommented Include /etc/apache2/extra/httpd-vhosts.conf in /private/var/appache2/httpd.conf
  2. Added test.local to /etc/hosts
  3. Added the following to /etc/apache2/extra/http2-vhosts.conf

    <VirtualHost *:80>
     ServerName test.local
     DocumentRoot /Users/me/test
     <Directory /Users/me/test>
       AllowOverride all
       Options -MultiViews
  4. Restarted Apache

    $ apachectl -t
    Syntax OK
    $ sudo apachectl graceful
    $ ping test.local
    PING test.local ( 56 data bytes
    64 bytes from icmp_seq=0 ttl=64 time=0.040 ms

...but again, nothing when I navigate to http://test.local

Any thoughts? Does this have something to do with Mavericks' new "Web Sharing" preference, which you have to download separately, or something?


Figured it out! I had to modify the main httpd.conf Directory options to AllowOverride All and Allow from All, as per this tutorial. The conf file that comes with Mavericks has this turned off. If I had looked at my original conf file on my old machine, I would have noticed the difference.

The other thing that was messing me up is that if I have

ErrorLog "/Users/me/error.log"

in my VirtualHost definition, I get "Chrome can't connect", even though Apache tells me the syntax is fine. Removing it resolves the problem.

Thanks all!

  • You have to pay for web sharing?
    – grg
    Commented Apr 17, 2014 at 14:21
  • As far as I understood, there is some new front-end to the server preferences that Apple wants you to pay for, but which you can avoid by modifying pref files directly. I may be mistaken on that, and I don't know if it relates to my question. In my "Sharing" folder, I don't see "Web Sharing" at all, whereas it used to be there in my 10.6.8
    – Sam Fen
    Commented Apr 17, 2014 at 14:29
  • no there is nothing you need to pay for except you want OS X Server. But even OS X Server does not make use of the pre-installed apache. You can download a custom preference pane on the web for free here : clickontyler.com/web-sharing
    – rwenz3l
    Commented Apr 17, 2014 at 15:51

3 Answers 3


Check /var/log/apache2/error_log or /var/log/system.log. You can also try to flush the DNS cache by running sudo killall -HUP mDNSResponder. See http://support.apple.com/kb/ht5343.

Just running sudo apachectl start makes http://localhost show the "It works!" page for me in a 10.9 VM.


<Directory "/Users/username/Sites/">
  Options Indexes Multiviews
  AllowOverride AuthConfig Limit
  Order allow,deny
  Allow from all

as /etc/apache2/users/username.conf and running sudo apachectl restart makes http://localhost/~username/ point to ~/Sites/.

Uncommenting Include /private/etc/apache2/extra/httpd-vhosts.conf in /etc/apache2/httpd.conf, adding test.dev to /etc/hosts, adding

<VirtualHost *:80>
  DocumentRoot "/Users/username/Sites/test"
  ServerName test.dev

to /etc/apache2/extra/httpd-vhosts.conf, and running sudo apachectl restart makes http://test.dev point to ~/Sites/test/.

  • The first block of text is what I added the the main httpd.conf file, and that worked. I'll accept this answer, since it's closest. Thanks!
    – Sam Fen
    Commented Apr 18, 2014 at 19:19

First of all, did you flush your DNS cache after changing the hosts file? Run dscacheutil -flushcache in Terminal.

Second, you can run apachectl -S to check your apache2 config. Correct any errors and restart apache again.

Third, check the permissions on your /Users/me/test directory. Chmod the permissions on that directory to 775 or even 777 to see if that helps.

  • 1. Ran it now. The cache was flushed (it took Chrome several seconds longer to try and resolve the site), but still says it cannot connect. 2. I get VirtualHost configuration: wildcard NameVirtualHosts and _default_ servers: *:80 is a NameVirtualHost, default server test.local (/private/etc/apache2/extra/httpd-vhosts.conf:29), port 80 namevhost test.local (/private/etc/apache2/extra/httpd-vhosts.conf:29). 3. chmod to 777 and it didn't help. Also, I would still expect to see the "It Works!" message at localhost even without a vhost, right?
    – Sam Fen
    Commented Apr 17, 2014 at 15:51
  • If you had a working setup under 10.6.8 your old httpd.conf file will be save at /etc/apache2/httpd.conf.pre-update. You can compare this with the current conf file to see if there are any other settings that are different.
    – JMS
    Commented Apr 17, 2014 at 15:58
  • yes you would. By simply doing : sudo apachectl start and entering "localhost" in firefox I see "It works" in the Browser.. Maybe you can try to use macports and install apache2 again, copy the "clean" config if you need to.
    – rwenz3l
    Commented Apr 17, 2014 at 15:59
  • Ok, actually if I re-comment the line Include /etc/apache2/extra/httpd-vhosts.conf in httpd.conf, and re-start Apache, I now see the "It Works!" message. Presumably this changed after the DNS cache flush. So now I just need to work out what's wrong with my vhosts file. But it should be an easier task now, thanks.
    – Sam Fen
    Commented Apr 17, 2014 at 16:11
  • After re-reading your original post, in your vhost section above, I think the DocumentRoot needs to be enclosed with quotes.
    – JMS
    Commented Apr 17, 2014 at 16:18

I've updated to Mavericks from Snow Leopard and my apache gave me hard time right away. After banging my head for two straight nights, reading everything about configuring Apache under Mavericks and seeing no progress on it whatsoever – I've been having "It works" message for every virtual host which was previously configured with SL and at some point even that stopped working – I've found that if you swap your old httpd.conf-previous with the newly generated httpd.conf, you should comment out LoadModule bonjour_module libexec/apache2/mod_bonjour.so, too. apachectl start (or restart) doesn't throw any errors, but it actually doesn't like this module at all. So comment this one line out.

I guess, the lesson is to triple-check every directive in the config. And bang your head less, too. ;/

You must log in to answer this question.

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