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/domain1.com, 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/domain1.com:

          # domain: domain1.com
          # public: /home/demo/public_html/domain1.com/

<VirtualHost *:80>

 # Admin email, Server Name (domain name) and any aliases
 ServerAdmin admin@domain1.com
 ServerName  domain1.com
 ServerAlias domain1.com

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

 # Custom log file locations
 LogLevel warn
 ErrorLog  /home/demo/public_html/domain1.com/log/error.log
 CustomLog /home/demo/public_html/domain1.com/log/access.log 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.


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.

  • 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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