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

If I type in my server ip address into a browser, it always goes to the lowest alphabetical domain on my server. So if I had these domain on my server:


...typing in the ip would take you to

If I then add to my server, typing the the ip in a browser would go to

How do I make the ip go to the primary domain on the server?

share|improve this question
up vote 6 down vote accepted

By using an IP address to access your server you are bypassing the DNS system so this has nothing to do with DNS or Bind.

If you are observing this as the response from a web server and the webserver is apache then my guess is that you are creating vhosts in such a manner that they are defined alphabetically. Without any way to differentiate between vhosts apache will serve the first vhost that was defined as the default vhost.

What you have to do is make your primary domain be defined as the first vhost on the server. If your primary domain is and it is defined in a file called rename the configuration file to something like

share|improve this answer
What does it have to do with then, and how would I fix it? – user1248979 May 12 '12 at 7:14
Would your idea be better than a2ensite'ing default again, and putting the same DocumentRoot/Directory path as the primary domain? – user1248979 May 12 '12 at 7:30
Creating a file which obviously comes first alphabetically is the way this is normally handled. Apache picks the first file it can find if the client connects via IP not name - just make your primary domain config file the first one alphabetically, as suggested. – EightBitTony May 12 '12 at 7:33
To clarify this comment a bit, Apache picks the first <NameVirtualHost> it finds for an IP Address that's using name-based virtual hosting. On systems using sites-enabled or a similar directory the contents of that directory are loaded in "ASCIIbetical order" (the order they show up in when you run ls). So the file that's first in the directory listing is loaded earliest, and "wins" by default. – voretaq7 Mar 7 '13 at 16:28

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.