I currently have a machine with multiple IPs, however I wish to limit Apache to just one of them.

I understand this question has been asked already here however I have run into issues following it: Limit Apache to a single IP

For the sake of simplicity, lets say I have an IP, which I want Apache to run on, meanwhile another IP, is available to Apache however I do not want Apache to touch this IP.

In my ports.conf:


<IfModule ssl_module>

<IfModule mod_gnutls.c>

Meanwhile, 000-default.conf:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

Using the configuration, there are no errors on startup, however when visiting in a browser, it appears to take me no to /var/www/html (the default Apache2 page) but rather to one of my sites currently running on the IP too.

Additonally, using:


Appear to allow you to visit in browser and get /var/www/html (the default Apache2 page) yet on startup using this configuration gives the error:

[Tue Aug 18 17:34:54.487039 2015] [core:error] [pid 5446] (EAI 2)Name or service not known: AH00549: Failed to resolve server name for (check DNS) -- or specify an explicit ServerName

I am stumped by this one, if anyone could show me as to what is going wrong, that would be great.


...or specify an explicit ServerName - here's the point. You have to be missing ServerName your.fqdn in your configuration. Ubuntu's httpd doesn't have it by default.

Go with <VirtualHost *:80> version. Create /etc/apache2/conf-available/servername.conf, put ServerName your.fqdn there, run a2enconf servername, then service apache2 reload. Remember to also set ServerName inside every VirtualHost block (may be skipped for default one).

Other than that, your IP configuration seems fine. Make sure 000-default.conf is enabled (a link present in /etc/apache2/sites-enabled).

  • Sorry, I don't understand what you mean, leave everything as it is and create a file called 'servername.conf' in /etc/apache2/conf-available/servername.conf and run a2enconf servername? What should I actually put in the servername.conf file? Remember I am running multiple sites off the one IP. Sorry, I am really new to all this. – dwilson390 Aug 18 '15 at 17:00
  • Edited the answer to make 2nd paragraph more clear. The proposed change doesn't interfere with name-based virtual hosting that you probably have configured (I assume this is what you mean by multiple sites off the one IP). – sam_pan_mariusz Aug 18 '15 at 18:22
  • Thank you, you helped me solve this issue. For reference, all virtual hosts need to use *:80 which is what was causing the issues regarding the server serving the wrong site. – dwilson390 Aug 18 '15 at 20:17

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.