Skip to main content

Apache handles 127.*.*.*:80 instead of just [Resolved]

I'd like Apache to only handle requests to so that I can use etc. for other applications, so I've tried changing the /etc/apache2/sites-enabled/000-default.conf to

     ServerName localhost
     ServerAdmin webmaster@localhost
     DocumentRoot /var/www/html
     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

and then I've restarted Apache, but it doesn't work. No other vhost rules are in place, output of apachectl -S is as follows:

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:           localhost (/etc/apache2/sites-enabled/000-default.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default 
PidFile: "/var/run/apache2/"
User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used

Question Credit: a51
Question Reference
Asked July 21, 2019
Posted Under: Network
1 Answers

The Listen directive is used to configure which address/port combinations that Apache httpd should bind to (or listen on, if you will).
When only a port is specified (no address), that means to bind to the specified port for all addresses.

The VirtualHost directive, on the other hand, is part of the configuration for how to respond to requests (like what content to serve, etc).
The address/port that is specified in this context is used to select for which incoming requests that Apache httpd should even attempt to use this VirtualHost.

If you only want Apache httpd to only bind to, you would do something like this as your only Listen directive:


credit: Håkan Lindqvist
Answered July 21, 2019
Your Answer