Apache: [warn] _default_ VirtualHost overlap on port 80, the first has precedence Error and Solution

by on November 2, 2008 · 36 comments· LAST UPDATED November 2, 2008

in , ,

Question:I'm using Apache 2 to host multiple site on a single host using Apache name based VirtualHost feature. However, Apache is displaying lots of warning as follows:

Performing sanity check on apache22 configuration:
[Portal Oct 05 06:59:34 2008] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
[Portal Oct 05 06:59:34 2008] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
[Portal Oct 05 06:59:34 2008] [warn] NameVirtualHost 81.aaa.www.yyy:80 has no VirtualHosts
Syntax OK
Stopping apache22.
Waiting for PIDS: 14968.
Syntax OK
Starting apache22.
[Portal Oct 05 06:59:36 2008] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
[Portal Oct 05 06:59:36 2008] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
[Portal Oct 05 06:59:36 2008] [warn] NameVirtualHost 81.aaa.www.yyy:80 has no VirtualHosts

How do I fix this warning and host multiple websites under UNIX / Linux Apache 2 webserver?

Answer: The NameVirtualHost directive is a required to configure name-based virtual hosts. Add this to your httpd.conf file to fix this issue. Open httpd.conf file:
# vi httpd.conf
Add NameVirtualHost as follows:
NameVirtualHost *:80
OR add server IP
NameVirtualHost 202.54.1.1:80
Save and close the file. Restart httpd web server under RHEL / Red Hat / Fedora / CentOS Linux:
# service httpd restart
OR type the following to restart Apache 2 under Debian / Ubuntu Linux:
# /etc/init.d/apache2 restart

Sample Apache 2 Virtual hosting configuration

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.

# My Virtual Hosts Config File for Two Domains
NameVirtualHost *:80
 
<VirtualHost *:80>
    ServerAdmin webmaster@theos.in
    DocumentRoot "/usr/local/docs/theos.in"
    ServerName www.theos.in
    ServerAlias theos.in
    ErrorLog "/var/log/theos.in-error_log"
    CustomLog "/var/log/theos.in-access_log" common
</VirtualHost>
 
<VirtualHost *:80>
    ServerAdmin webmaster@nixcraft.com
    DocumentRoot "/usr/local/docs/nixcraft.com"
    ServerName www.nixcraft.com
    ServerAlias nixcraft.com
    ErrorLog "/var/log/nixcraft.com-error_log"
    CustomLog "/var/log/nixcraft.com-access_log" common
</VirtualHost>
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 36 comments… read them below or add one }

1 4F2E4A2E February 4, 2009 at 11:37 pm

is not working for me… really dont know why… its always taking the first entry…

my domain provider:
-----------halbgasse.at:
http://80.108.98.115
-----------hebron.at:
http://80.108.98.115

—————/etc/apache2/sites-available:

NameVirtualHost *:80
    ServerAdmin webmaster@halbgasse.at
    DocumentRoot "/var/www/halbgasse"
    ServerName www.halbgasse.at
    ServerAlias halbgasse.at
    ErrorLog "/home/www/halbgasse_error_log"
    CustomLog "/home/www/halbgasse_in-access_log" common
    ServerAdmin webmaster@hebron.at
    DocumentRoot "/var/www/hebron"
    ServerName www.hebron.at
    ServerAlias hebron.at
    ErrorLog "/home/www/hebron_error_log"
    CustomLog "/home/www/hebron_access_log" common
-------------------------------------------------------------

Reply

2 mnorland February 19, 2009 at 8:35 pm

The NameVirtualHost *:80 directive should go in your httpd.conf – sites available is generally symlinks of the actual virtual hosts.

Reply

3 freelancer March 2, 2009 at 5:37 am

Thanks a lot.
NameVirtualHost *:80

It’s very usefull

Reply

4 napolik April 24, 2009 at 5:53 am

Thanks. NameVirtualHost *:80 help with all my problems.

PS Sorry for my English =)

Reply

5 Seth May 2, 2009 at 2:11 pm

Yup, needed this reminder again when I migrated all my sites to a new VPS :)

Reply

6 xmen May 13, 2009 at 6:24 pm

# My Virtual Hosts Config File for Two Domains
NameVirtualHost *:80

ServerAdmin webmaster@theos.in
DocumentRoot “/usr/local/docs/theos.in”
ServerName http://www.theos.in
ServerAlias theos.in
ErrorLog “/var/log/theos.in-error_log”
CustomLog “/var/log/theos.in-access_log” common

ServerAdmin webmaster@nixcraft.com
DocumentRoot “/usr/local/docs/nixcraft.com”
ServerName http://www.nixcraft.com
ServerAlias nixcraft.com
ErrorLog “/var/log/nixcraft.com-error_log”
CustomLog “/var/log/nixcraft.com-access_log” common

When I configure the same file , I have a problem. I used Firefox, everytime I type http://www.theos.in or http://www.nixcraft.com, I only see mainpage (theos.in), no nixcraft.com

Reply

7 4F2E4A2E September 4, 2009 at 7:52 am

thx alot
every thing working fine now :)

Reply

8 iNovek October 7, 2009 at 9:06 pm

I’ve read many forum-posts with really crazy answers to this error message. And this litte * fix it. Thanks.

Reply

9 Omar Yepez January 15, 2010 at 8:35 pm

Thanks very muchhhhhhhhhhhhhhhhhh

Reply

10 Ben February 2, 2010 at 9:11 pm

Hi all i don t understund why it s always the first entry that is taken into account ??
I don t understund at all
Please help me

Reply

11 egoleo March 13, 2010 at 7:29 am

thank dude. it works like magic.

Reply

12 Luke March 27, 2010 at 5:16 pm

Finally it fixed.

I’ve had this problem on an Ubuntu Server for the whole time I’ve been running it (about 18 months) and have just avoided using Apache on it since I couldn’t find a fix and it seemed to work fine everywhere else. Now its fixed and I can use it properly.

My eternal gratitude!!!!

Reply

13 Alisson June 29, 2010 at 6:40 pm

Thanks a LOT!

simple and fantastic

NameVirtualHost *:80

:)

Reply

14 Oscar July 17, 2010 at 2:35 am

I want to say “Thanks a LOT”.
I have 15 days looking for a help, finally i found it.

Reply

15 Sid September 20, 2010 at 6:22 pm

Thank you so much For that post!

Reply

16 Marc February 5, 2011 at 8:26 am

Hi,
Thanks for all. It’s up
Regards
Marc

Reply

17 Olfried February 28, 2011 at 8:44 pm

If you use Ubutu 10.10 as server and have configured as they suppose
For example:
under apache2/sites-enabled/eww.test.de
with the content:
# —————–
# eww.test.de
# ——————————————————-

ServerName eww.test.de
ServerAlias eww.test.de
ServerAdmin admin@localhost
ErrorLog /var/log/httpd/test-error_log
CustomLog /var/log/httpd/test-access_log common
DocumentRoot /home/eww/local

and edit your /etc/apache2/apache2.conf to add “NameVirtualHost *:80″
beware that you don’t add this at the end of the file instead put it over
>Include httpd.conf< or add this directive in the httpd.conf.
It took some hours of "service apache2 restart" until I found it.

Reply

18 Olfried February 28, 2011 at 8:47 pm

Oops, the blog eat my <
Again the eww.test.de content\

# -----------------
# eww.test.de
# -------------------------------------------------------
<VirtualHost *:80>
ServerName eww.test.de
ServerAlias eww.test.de
ServerAdmin ernst@localhost
ErrorLog /var/log/httpd/test-error_log
CustomLog /var/log/httpd/test-access_log common
DocumentRoot /home/eww/local
<Directory /home/eww/local>
#	AllowOverride None
#	Order Allow,Deny
#	Allow from all
#	Options +Indexes
</Directory>
</VirtualHost>

Reply

19 tukdalang May 31, 2011 at 2:52 am

Terima kasih banyak ….. after many days i lookingfor this, i get the answer
simple but very important
NameVirtualHost *:80

Thankyu very much….:)

Reply

20 TK Kocheran June 13, 2011 at 8:34 pm

Thanks, this helps a lot.

Reply

21 Pablo August 30, 2011 at 11:11 pm

Thanks, work fine for me.

Reply

22 Brian Lacy September 13, 2011 at 4:14 pm

If you find yourself really stuck with this error, make sure that ALL of your VirtualHosts’ port designators match the port designated on the NameVirtualHost directive!

For instance:

NameVirtualHost *:80
    # Some Apache Directives

That will result in the Port Overlap error because your VHost port doesn’t match the NameVirtualHost port.

Reply

23 Brian Lacy September 13, 2011 at 4:15 pm

Oops, that last should have been:

NameVirtualHost *:80
<VirtualHost *>
    # Some Apache Directives
</VirtualHost >

Reply

24 Amit December 17, 2011 at 8:10 pm

Thanks man u saved me…..this virtual hosting made me almost crazy in last 2-3 month

Reply

25 ctopher916 March 22, 2012 at 2:18 pm

Thanks for this info. I couldn’t figure out why my virtual host config was not working. The Apache error message is not very useful for this problem.

Reply

26 Angelo May 1, 2012 at 6:29 pm

Thanks guy.

You have solved my problem.

Reply

27 Andres May 29, 2012 at 7:31 pm

Also remember, at least on Red-hat based distors, that all the site configurations are loaded from /etc/httpd/conf.d in alphabetical order making the first one the default virtual host.

Reply

28 Vivek August 31, 2012 at 7:10 am

Cheers..!!
You have resolve my problem.

Reply

29 TAD September 13, 2012 at 11:34 am

For all of you who got problem.

This line : NameVirtualHost *:80 MUST be just before :

    ServerAdmin webmaster@theos.in
    DocumentRoot "/usr/local/docs/theos.in"
    ServerName www.theos.in
    ServerAlias theos.in
    ErrorLog "/var/log/theos.in-error_log"
    CustomLog "/var/log/theos.in-access_log" common
    ServerAdmin webmaster@nixcraft.com
    DocumentRoot "/usr/local/docs/nixcraft.com"
    ServerName www.nixcraft.com
    ServerAlias nixcraft.com
    ErrorLog "/var/log/nixcraft.com-error_log"
    CustomLog "/var/log/nixcraft.com-access_log" common

Thx for this tweak !

Reply

30 Jordan September 21, 2012 at 4:38 pm

Greate!
Thanks!

Reply

31 Terry October 5, 2012 at 4:20 pm

Thank you!

Reply

32 Saku February 22, 2013 at 4:30 pm

Tahnks, just what I needed for my Ubuntu server

Reply

33 John May 30, 2013 at 11:46 pm

Thanks, that was what was missing :D

Reply

34 Alexandra July 12, 2013 at 7:27 pm

Thank you! You solved my configuration problem. Just googled and found this solution

Reply

35 JustinM November 4, 2013 at 1:00 am

Awesome, this totally helped me get set up. I upgraded to Mavericks in-place from Lion, and my Apache vhosts were completely fubared until I found your post. Thanks!

Reply

36 yoosaf March 7, 2014 at 4:40 pm

Thanks a lot!!!

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: