I am perplexed about the problem I am having and would really appreciate help resolving it.

I have an iMac running Mac OS X Mavericks 10.9.2

I have set up my apache to serve documents from the server root /Volume/sites/

I am using Dynamic Virtual hosts, so just by adding a directory with the *.dev suffix, it becomes a virtual host.

My hosts file is pretty basic:

# Host Database
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##         localhost   broadcasthost
::1               localhost
fe80::1%lo0       localhost

My httpd-vhosts.conf file is as follows:

# Virtual Hosts
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
# You may use the command line option '-S' to verify your virtual host
# configuration.

# Use name-based virtual hosting.
NameVirtualHost *:80

# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.

#allow access to the Hosts directory where your sites are
<Directory "/Volumes/sites">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    #you could configure the following to only allow access from localhost
    Order allow,deny
    Allow from all

#get the server name from the Host: header
UseCanonicalName Off
VirtualDocumentRoot /Volumes/sites/%0/

This all worked. And I have not changed anything in my httpd.conf file.

Yet I can't load localhost

I also cannot load

I ran the command sudo lsof -i :80 | egrep "PID|LISTEN" to see if any PID was listening on port 80. The results were empty.

I have tried to restart apache and also to stop and then start apache using

sudo apachectl stop sudo apachectl start

sudo apachectl restart

Nothing works.

I checked if apache was running by issuing the command httpd -v

The return was:

Server version: Apache/2.2.26 (Unix)
Server built:   Dec 10 2013 22:09:38

I tried to connect to localhost and via the command line with the following result:

alisamii at alisamii in ~
$ telnet localhost 80
Trying ::1...
telnet: connect to address ::1: Connection refused
telnet: connect to address Connection refused
Trying fe80::1...
telnet: connect to address fe80::1: Connection refused
telnet: Unable to connect to remote host
alisamii at alisamii in ~
$ telnet 80
telnet: connect to address Connection refused
telnet: Unable to connect to remote host
alisamii at alisamii in ~
$ lynx http://localhost

Looking up localhost
Making HTTP connection to localhost
Alert!: Unable to connect to remote host.

lynx: Can't access startfile http://localhost/
alisamii at alisamii in ~
$ lynx

Looking up
Making HTTP connection to
Alert!: Unable to connect to remote host.

lynx: Can't access startfile
alisamii at alisamii in ~

Please help.

  • What did you do with this problem, as I am experiencing exactly the same thing here :( Mar 10, 2017 at 21:55
  • Clearing cookies and site data cleared this error for me on MacOs High Sierra. Jul 6, 2021 at 15:45

6 Answers 6


Had the same problem. I deleted one of my project's folder and it became broken. In this case the site's configs should be removed from httpd-vhosts.conf and httpd.conf.

Try ping

apachectl configtest can help you to detect the problem.

  • 7
    Absolutely correct, apachectl configtest need to be your first try! Thanks. Mar 31, 2015 at 15:24
  • Warning: DocumentRoot [/Users/me/blah/blah] does not exist you can quickly find the offending line with sudo cd / && grep -rn "/Users/me/blah/blah" *
    – Shanimal
    Jun 25, 2016 at 19:53

The problem could be that the hosts file might have been corrupted from the original ASCII encoding. I cleared all spaces and put tabs in it, ran sudo killall -HUP mDNSResponder (you can do that instead of rebooting) and after, it worked.

  • 1
    Yes, /etc/hosts was corrupted — duplicate lines, some spaces where there once were tabs... now to figure out how that happened.... Feb 20, 2015 at 9:09
  • Especially check the localhost line in /etc/hosts Should be something like : localhost After upgrading to php 7.4 with brew my file was corrupted and became (ie the space was missing)
    – Erwan
    Apr 24, 2020 at 22:49

Refused connections are most commonly caused by a server that is not listening to the port.

Syntax errors or general config file errors will kill apache at startup (usually without reporting to error logs or terminal).

Try running sudo apachectl configtest and see if it outputs any error messages.


In my case, the issue was that the folder /private/var/log/apache2/ was gone missing for unknown reasons. Recreating it with

sudo mkdir /private/var/log/apache2

and restarting apache with

sudo apachectl restart

made the trick!


It's Mac specific. First you have to enable Web Sharing. For Maveric it can be done as in this tutorial. https://www.youtube.com/watch?v=TgiZiTU9JVY Second, for Mac the traffic if filtered via pfctl(i.e. man pfctl) in Maveric and ipfw(man ipfw) for older version of Mac OS if you need more than port 80

  • Answers on Ask Different need to be more than just a link. It's okay to include a link, but please summarize or excerpt it in the answer. The idea is to make the answer stand alone.
    – nohillside
    Jun 27, 2015 at 8:03

This might help with your query. http://mallinson.ca/web-development-with-mavericks/

  • Please try to explain your answer to the query rather than just posting a link.
    – Jash Jacob
    Sep 13, 2014 at 2:38

You must log in to answer this question.

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