Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to set up multiple domains with virtual hosts in Apache2. I'm currently getting a "Could not connect" error when I try to browse to my site, and whenever I try to restart Apache2, I get an error about "no listening sockets available, shutting down Unable to open logs".

Originally, after configuring apache2.conf and my /apache2/sites-enabled/, I was getting a 500 server error and a warn from apache2 that "NameVirtualHost *:80 has no VirtualHosts". Then I commented out an extra (I think) NameVirtualHost *:80 in the ports.conf file, and now the cannot connect and no sockets error.

Here's what's at the bottom of my apache2.conf:

 NameVirtualHost *:80
#<VirtualHost *:80>                                                            

<IfModule mod_ssl.c>
    NameVirtualHost *:443

And my /apache2/sites-enabled/

          # domain:
          # public: /home/demo/public_html/

<VirtualHost *:80>

 # Admin email, Server Name (domain name) and any aliases

 # Index file and Document Root (where the public files are located)
 DirectoryIndex index.html
 DocumentRoot /home/demo/public_html/

 # Custom log file locations
 LogLevel warn
 ErrorLog  /home/demo/public_html/
 CustomLog /home/demo/public_html/ combined


And finally, my ports.conf:

#NameVirtualHost *:80                                                            
#Listen 80                                                                     

<IfModule mod_ssl.c>
    # If you add NameVirtualHost *:443 here, you will also have to change      
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl    
    # to <VirtualHost *:443>                                                   
    # Server Name Indication for SSL named virtual hosts is currently not      
    # supported by MSIE on Windows XP.                                         
        Listen 443

<IfModule mod_gnutls.c>
    Listen 443

I appreciate any insight that can be offered.

share|improve this question
up vote 8 down vote accepted

It looks like you've commented out the Listen 80 line, so Apache isn't listening on the normal http port.

You're other Listen directives are inside IfModule blocks, so if those modules aren't present, you have effectively configured Apache to not listen on any ports, which may be the source of your error.

Try uncommenting the line:

Listen 80

In your ports.conf.

share|improve this answer
Awesome, thank you! Now I'm getting a 500 server error, and not just that terrifying no connection. I'll go bang on it a bit more, try and fix that. Again, thanks. – Ana Oct 27 '11 at 3:50
...and up and fixed entirely. – Ana Oct 27 '11 at 4:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.