When my Ubuntu Apache server (Apache 2) starts up I get a warning message that reads:

[warn] NameVirtualHost *:80 has no VirtualHosts

However, the web server is working fine. What might I have wrong in my site's configuration to make it give me this warning?

The configuration file in question (located in /etc/apache2/sites-available) reads like (details removed for brevity)

<VirtualHost *>
    <Location /mysite>
        # Configuration details here...

    # Use the following for authorization.
    <LocationMatch "/mysite/login">
        AuthType Basic
        AuthName "My Site"
        AuthUserFile /etc/sitepasswords/passwd
        Require valid-user

Could the fact that I'm using <Location> be a part of the problem?


7 Answers 7



<VirtualHost *>

to read

<VirtualHost *:80>

Or its (NameVirtualHost *:80) added twice in your apache2 Confing file. ( By Default its added in ports.conf file )

This should clear the error.

Aside: you shouldn't ignore this error. Apache's config, especially when globbing virtual hosts (eg Include /etc/httpd/vhosts.d/*) is not stable. That means you don't control the order of loading the hosts explicitly so the default vhost for an IP becomes the one that is loaded first, which can lead to unintended consequences.

One example of this is the default vhost for an IP will also be available on that IP, rather than its name. This can cause information to leak onto google referring to your sites IP rather than name, which can be confusing for customers.

The NameVirtualHost error above can be a hint that apache has loaded things in a non optimal way, so you shouldn't ignore it.

  • 5
    You can set the default vhost like this: <VirtualHost _default_ thehostname.com>
    – Amy B
    Oct 10, 2010 at 12:49

That could be because you have the NameVirtualHost directive in more than one place.

I don't know about other distributions, but in Ubuntu/Debian, Apache's configuration is split in several files, so you'd have to check where the duplication is (httpd.conf, apache2.conf, ports.conf, conf.d/*).

Oh, and I just found this great resource with more information: Common Apache Misconfigurations.

  • 3
    The link you gave looks like a great resource for trying to understand the nuances of Apache config files. Thanks!
    – Kit Roed
    Apr 30, 2009 at 18:35
  • 4
    Thanks! This was my problem - I had created a virtual.conf for NameVirtualHost, not knowing it was already in ports.conf
    – rcampbell
    Oct 23, 2009 at 14:13
  • Thanks - Same problem here in a ubuntu server default configuration: ports.conf contains NameVirtualHost :80 and should not be repeated in the sites-enabled/ config files!
    – DrSAR
    Apr 30, 2011 at 23:22
  • 1
    In my case, this issue was because ubuntu had NameVirtualHost *:80 both in ports.conf and in conf.d/virtualhosts, which appears to be an Ubuntu bug.
    – fluffy
    Jul 30, 2012 at 3:10

On a Debian/Lenny box: In /etc/apache2/ports.conf there is an additional NameVirtualHost statement - that could be the cause for this issue (there is also the same statement in /etc/apache2/sites-available/default). I commented that statement and the error disappered.


You have a NameVirtualHost without a matching VirtualHost entry.

This is typically not fatal, just an informative error.


It's because your NameVirtualHost line has a port number on it (:80), but your VirtualHost sections don't.


AS Rune mentions, on Debian systems NameVirtualHost appears in many files - ports.conf, conf.d/virtual.conf and possibly your own conf files int sites-available

Make sure it exists in one place as NameVirtualHost *:80 (mine is in conf.d/virtual.conf) and the warnings should go.

As mentioned you also need to make the VirtualHost direction for each site-available have this format <VirtualHost *:80>


I have the same problem, but I disable the default site of Apache in some moment. I type something like

# a2dissite default

After I try to restart Apache 2, I receive this message:

"[warn] NameVirtualHost *:80 has no VirtualHosts"

Then I enable the 'default' site of Apache 2 again and everything works again, the command used is:

# a2ensite default

That's all folks!

  • This has been the best advice. Aug 26, 2011 at 4:58
  • Awesome advice, i'm running zpanelCP and nothing worked but this. thanks ! :) Aug 29, 2015 at 8:47

You must log in to answer this question.

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