By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

NameVirtualHost :80 has no VirtualHosts

How to solve a problem with NameVirtualHost having no VirtualHosts in Apache on Ubuntu.

Edited: 2015-11-07 17:11

After installing apache you might be getting a message telling you that NameVirtualHost doesn't have any VirtualHosts. I.e.

NameVirtualHost *:80 has no VirtualHosts

This can happen when you have changed your 000-default file and started adding Virtual Hosts. By default Apache has been setup to handle all hosts in one VirtualHost. I.e. In your 000-default file you likely have something like:

<VirtualHost *:80>

And in the ports.conf file you would have something like:

NameVirtualHost *:80

This means that if either you have local domains listed in your etc/hosts file, or if the dns settings of a real domain points to your server WAN ip, they will all be handled by the same VirtualHost.

To solve this problem just remove the NameVirtualHost *:80 setting, and add your own NameVirtualHost'(s) instead – and also keep in mind that a NameVirtualHost must match a VirtualHost block in your 000-default file. In the below example we just uncommented the *:80 setting and added our own instead.

# NameVirtualHost *:80
NameVirtualHost my-host:80

Where my-host is just a locally hosted domain like localhost, listed in the host file of your operating system. Note the missing domain extension – like .com, .net. Etc. – extensions are not needed for domains hosted locally. Pretty cool eh?!