Apache - server not resolving by /etc/hosts if I have not internet connection





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







4















I have configured many virtualhosts in my current apache2 server, in my local machine (Ubuntu 13.10).



Those are different local sites, with domains which are set in my /etc/hosts:



127.0.0.1       localhost
127.0.0.1 agroplasticos.dev
127.0.0.1 resources.dev
127.0.1.1 luismasuelli-inspiron14

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters


Where the agroplasticos.dev and resources.dev sites were created by me, and the previous settings were set by default.



For localhost, agroplasticos.dev, and resources.dev, I have site entries in /etc/apache2/sites-enabled directory (only those 3 entries exist in this directory), which are links to the corresponding files in /etc/apache2/sites-available:



agroplasticos.dev looks like:



<VirtualHost agroplasticos.dev:80>
ServerName agroplasticos.dev:80
ServerAdmin webmaster@localhost

DocumentRoot /var/www/agroplasticos
<Directory /var/www/agroplasticos>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/agroplasticos-error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/agroplasticos-access.log combined
</VirtualHost>


and resources.dev looks like:



<VirtualHost resources.dev:80>
ServerName resources.dev:80
ServerAdmin webmaster@localhost

DocumentRoot /var/www/resources
<Directory /var/www/resources>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/resources-error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/resources-access.log combined
</VirtualHost>


And -last but not least- localhost looks like this:



<VirtualHost localhost:80>
ServerName localhost:80
ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


What I expect is that if I access such domains, they are resolved to 127.0.0.1 and they are served by apache using the different settings for each site. In particular, resources.dev is just a static files website (it has only images I load externally via http from programs / scripts I'm making), so I don't care about even having PHP for such site. This means: I hit http://resources.dev/mirrorlings/images/sample.png in my browser, and I retrieve an image.



However -and there's the catch- the site is successfully mounted if I have network connection. If i'm not connected, then:




  1. I can access http://localhost/ (the sample, never-modified, "it works" screen appears).

  2. I cannot access http://resources.dev/ (the server did not mount it; http clients like browsers or ActionScript loaders cannot reach such url).

  3. I cannot access http://agroplasticos.dev/ (the server did not mount it; same about http clients).


  4. I'm getting this error log when running sudo service apache2 restart:



    [Sun Jul 20 15:39:55 2014] [error] (111)Connection refused: Could not resolve host name localhost -- ignoring!
    [Sun Jul 20 15:39:55 2014] [error] (111)Connection refused: Could not resolve host name agroplasticos.dev -- ignoring!
    [Sun Jul 20 15:39:55 2014] [warn] The Alias directive in /etc/apache2/conf.d/phpmyadmin.conf at line 3 will probably never match because it overlaps an earlier Alias.
    [Sun Jul 20 15:39:55 2014] [error] (111)Connection refused: Could not resolve host name agroplasticos.dev -- ignoring!
    [Sun Jul 20 15:39:55 2014] [error] (111)Connection refused: Could not resolve host name localhost -- ignoring!
    [Sun Jul 20 15:39:55 2014] [error] (111)Connection refused: Could not resolve host name resources.dev -- ignoring!
    apache2: apr_sockaddr_info_get() failed for luismasuelli-inspiron14
    apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
    [Sun Jul 20 15:39:56 2014] [error] (111)Connection refused: Could not resolve host name localhost -- ignoring!
    [Sun Jul 20 15:39:56 2014] [error] (111)Connection refused: Could not resolve host name agroplasticos.dev -- ignoring!
    [Sun Jul 20 15:39:56 2014] [warn] The Alias directive in /etc/apache2/conf.d/phpmyadmin.conf at line 3 will probably never match because it overlaps an earlier Alias.
    [Sun Jul 20 15:39:56 2014] [error] (111)Connection refused: Could not resolve host name agroplasticos.dev -- ignoring!
    [Sun Jul 20 15:39:56 2014] [error] (111)Connection refused: Could not resolve host name localhost -- ignoring!
    [Sun Jul 20 15:39:56 2014] [error] (111)Connection refused: Could not resolve host name resources.dev -- ignoring!
    apache2: apr_sockaddr_info_get() failed for luismasuelli-inspiron14
    apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName


    Also do not understand why does this log appeared twice. You can see the same line block is repeated with one-second delay.




And my question here: Why do I need to have internet connection when what I want is that Apache resolved such fake domains as local, since they are in /etc/hosts? What do I have to configure in order to allow local, networkless, resolution?



I was trying to develop without having internet connection and could not hit my local servers using local /etc/hosts domain resolution to local (loopback) ip address.










share|improve this question














bumped to the homepage by Community 5 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.











  • 1





    Have you tried VirtualHost *:80 instead of VirtualHost <fdqn>:80?

    – muru
    Jul 21 '14 at 5:51











  • I'm not in that pc right now. Will that solve it? I thought <fqdn>:80 was like a pattern which was only matched for that file (i.e. I thought that, by doing what you say, every file would match every local domain)

    – Luis Masuelli
    Jul 21 '14 at 21:31













  • that was my impression too, when I was trying to add a host. But no, Apache can use only the request fdqn and the ServerName/ServerAlias values to work. And for me, using fqdns in the virtualhost spec only caused problems.

    – muru
    Jul 22 '14 at 2:04











  • I think the DNS resolver needs to look up the .dev top level domain first, to see what DNS server is authorative for it. Not finding a server for your domains, it falls back to the hosts file.

    – Jos
    Jun 19 '16 at 14:48











  • I think @muru should be right. Try with <VirtualHost *:80> and ServerName agroplasticos.dev. I have explored this case, according to this post: askubuntu.com/q/824086/566421

    – pa4080
    Oct 19 '16 at 17:50


















4















I have configured many virtualhosts in my current apache2 server, in my local machine (Ubuntu 13.10).



Those are different local sites, with domains which are set in my /etc/hosts:



127.0.0.1       localhost
127.0.0.1 agroplasticos.dev
127.0.0.1 resources.dev
127.0.1.1 luismasuelli-inspiron14

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters


Where the agroplasticos.dev and resources.dev sites were created by me, and the previous settings were set by default.



For localhost, agroplasticos.dev, and resources.dev, I have site entries in /etc/apache2/sites-enabled directory (only those 3 entries exist in this directory), which are links to the corresponding files in /etc/apache2/sites-available:



agroplasticos.dev looks like:



<VirtualHost agroplasticos.dev:80>
ServerName agroplasticos.dev:80
ServerAdmin webmaster@localhost

DocumentRoot /var/www/agroplasticos
<Directory /var/www/agroplasticos>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/agroplasticos-error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/agroplasticos-access.log combined
</VirtualHost>


and resources.dev looks like:



<VirtualHost resources.dev:80>
ServerName resources.dev:80
ServerAdmin webmaster@localhost

DocumentRoot /var/www/resources
<Directory /var/www/resources>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/resources-error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/resources-access.log combined
</VirtualHost>


And -last but not least- localhost looks like this:



<VirtualHost localhost:80>
ServerName localhost:80
ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


What I expect is that if I access such domains, they are resolved to 127.0.0.1 and they are served by apache using the different settings for each site. In particular, resources.dev is just a static files website (it has only images I load externally via http from programs / scripts I'm making), so I don't care about even having PHP for such site. This means: I hit http://resources.dev/mirrorlings/images/sample.png in my browser, and I retrieve an image.



However -and there's the catch- the site is successfully mounted if I have network connection. If i'm not connected, then:




  1. I can access http://localhost/ (the sample, never-modified, "it works" screen appears).

  2. I cannot access http://resources.dev/ (the server did not mount it; http clients like browsers or ActionScript loaders cannot reach such url).

  3. I cannot access http://agroplasticos.dev/ (the server did not mount it; same about http clients).


  4. I'm getting this error log when running sudo service apache2 restart:



    [Sun Jul 20 15:39:55 2014] [error] (111)Connection refused: Could not resolve host name localhost -- ignoring!
    [Sun Jul 20 15:39:55 2014] [error] (111)Connection refused: Could not resolve host name agroplasticos.dev -- ignoring!
    [Sun Jul 20 15:39:55 2014] [warn] The Alias directive in /etc/apache2/conf.d/phpmyadmin.conf at line 3 will probably never match because it overlaps an earlier Alias.
    [Sun Jul 20 15:39:55 2014] [error] (111)Connection refused: Could not resolve host name agroplasticos.dev -- ignoring!
    [Sun Jul 20 15:39:55 2014] [error] (111)Connection refused: Could not resolve host name localhost -- ignoring!
    [Sun Jul 20 15:39:55 2014] [error] (111)Connection refused: Could not resolve host name resources.dev -- ignoring!
    apache2: apr_sockaddr_info_get() failed for luismasuelli-inspiron14
    apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
    [Sun Jul 20 15:39:56 2014] [error] (111)Connection refused: Could not resolve host name localhost -- ignoring!
    [Sun Jul 20 15:39:56 2014] [error] (111)Connection refused: Could not resolve host name agroplasticos.dev -- ignoring!
    [Sun Jul 20 15:39:56 2014] [warn] The Alias directive in /etc/apache2/conf.d/phpmyadmin.conf at line 3 will probably never match because it overlaps an earlier Alias.
    [Sun Jul 20 15:39:56 2014] [error] (111)Connection refused: Could not resolve host name agroplasticos.dev -- ignoring!
    [Sun Jul 20 15:39:56 2014] [error] (111)Connection refused: Could not resolve host name localhost -- ignoring!
    [Sun Jul 20 15:39:56 2014] [error] (111)Connection refused: Could not resolve host name resources.dev -- ignoring!
    apache2: apr_sockaddr_info_get() failed for luismasuelli-inspiron14
    apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName


    Also do not understand why does this log appeared twice. You can see the same line block is repeated with one-second delay.




And my question here: Why do I need to have internet connection when what I want is that Apache resolved such fake domains as local, since they are in /etc/hosts? What do I have to configure in order to allow local, networkless, resolution?



I was trying to develop without having internet connection and could not hit my local servers using local /etc/hosts domain resolution to local (loopback) ip address.










share|improve this question














bumped to the homepage by Community 5 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.











  • 1





    Have you tried VirtualHost *:80 instead of VirtualHost <fdqn>:80?

    – muru
    Jul 21 '14 at 5:51











  • I'm not in that pc right now. Will that solve it? I thought <fqdn>:80 was like a pattern which was only matched for that file (i.e. I thought that, by doing what you say, every file would match every local domain)

    – Luis Masuelli
    Jul 21 '14 at 21:31













  • that was my impression too, when I was trying to add a host. But no, Apache can use only the request fdqn and the ServerName/ServerAlias values to work. And for me, using fqdns in the virtualhost spec only caused problems.

    – muru
    Jul 22 '14 at 2:04











  • I think the DNS resolver needs to look up the .dev top level domain first, to see what DNS server is authorative for it. Not finding a server for your domains, it falls back to the hosts file.

    – Jos
    Jun 19 '16 at 14:48











  • I think @muru should be right. Try with <VirtualHost *:80> and ServerName agroplasticos.dev. I have explored this case, according to this post: askubuntu.com/q/824086/566421

    – pa4080
    Oct 19 '16 at 17:50














4












4








4


2






I have configured many virtualhosts in my current apache2 server, in my local machine (Ubuntu 13.10).



Those are different local sites, with domains which are set in my /etc/hosts:



127.0.0.1       localhost
127.0.0.1 agroplasticos.dev
127.0.0.1 resources.dev
127.0.1.1 luismasuelli-inspiron14

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters


Where the agroplasticos.dev and resources.dev sites were created by me, and the previous settings were set by default.



For localhost, agroplasticos.dev, and resources.dev, I have site entries in /etc/apache2/sites-enabled directory (only those 3 entries exist in this directory), which are links to the corresponding files in /etc/apache2/sites-available:



agroplasticos.dev looks like:



<VirtualHost agroplasticos.dev:80>
ServerName agroplasticos.dev:80
ServerAdmin webmaster@localhost

DocumentRoot /var/www/agroplasticos
<Directory /var/www/agroplasticos>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/agroplasticos-error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/agroplasticos-access.log combined
</VirtualHost>


and resources.dev looks like:



<VirtualHost resources.dev:80>
ServerName resources.dev:80
ServerAdmin webmaster@localhost

DocumentRoot /var/www/resources
<Directory /var/www/resources>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/resources-error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/resources-access.log combined
</VirtualHost>


And -last but not least- localhost looks like this:



<VirtualHost localhost:80>
ServerName localhost:80
ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


What I expect is that if I access such domains, they are resolved to 127.0.0.1 and they are served by apache using the different settings for each site. In particular, resources.dev is just a static files website (it has only images I load externally via http from programs / scripts I'm making), so I don't care about even having PHP for such site. This means: I hit http://resources.dev/mirrorlings/images/sample.png in my browser, and I retrieve an image.



However -and there's the catch- the site is successfully mounted if I have network connection. If i'm not connected, then:




  1. I can access http://localhost/ (the sample, never-modified, "it works" screen appears).

  2. I cannot access http://resources.dev/ (the server did not mount it; http clients like browsers or ActionScript loaders cannot reach such url).

  3. I cannot access http://agroplasticos.dev/ (the server did not mount it; same about http clients).


  4. I'm getting this error log when running sudo service apache2 restart:



    [Sun Jul 20 15:39:55 2014] [error] (111)Connection refused: Could not resolve host name localhost -- ignoring!
    [Sun Jul 20 15:39:55 2014] [error] (111)Connection refused: Could not resolve host name agroplasticos.dev -- ignoring!
    [Sun Jul 20 15:39:55 2014] [warn] The Alias directive in /etc/apache2/conf.d/phpmyadmin.conf at line 3 will probably never match because it overlaps an earlier Alias.
    [Sun Jul 20 15:39:55 2014] [error] (111)Connection refused: Could not resolve host name agroplasticos.dev -- ignoring!
    [Sun Jul 20 15:39:55 2014] [error] (111)Connection refused: Could not resolve host name localhost -- ignoring!
    [Sun Jul 20 15:39:55 2014] [error] (111)Connection refused: Could not resolve host name resources.dev -- ignoring!
    apache2: apr_sockaddr_info_get() failed for luismasuelli-inspiron14
    apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
    [Sun Jul 20 15:39:56 2014] [error] (111)Connection refused: Could not resolve host name localhost -- ignoring!
    [Sun Jul 20 15:39:56 2014] [error] (111)Connection refused: Could not resolve host name agroplasticos.dev -- ignoring!
    [Sun Jul 20 15:39:56 2014] [warn] The Alias directive in /etc/apache2/conf.d/phpmyadmin.conf at line 3 will probably never match because it overlaps an earlier Alias.
    [Sun Jul 20 15:39:56 2014] [error] (111)Connection refused: Could not resolve host name agroplasticos.dev -- ignoring!
    [Sun Jul 20 15:39:56 2014] [error] (111)Connection refused: Could not resolve host name localhost -- ignoring!
    [Sun Jul 20 15:39:56 2014] [error] (111)Connection refused: Could not resolve host name resources.dev -- ignoring!
    apache2: apr_sockaddr_info_get() failed for luismasuelli-inspiron14
    apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName


    Also do not understand why does this log appeared twice. You can see the same line block is repeated with one-second delay.




And my question here: Why do I need to have internet connection when what I want is that Apache resolved such fake domains as local, since they are in /etc/hosts? What do I have to configure in order to allow local, networkless, resolution?



I was trying to develop without having internet connection and could not hit my local servers using local /etc/hosts domain resolution to local (loopback) ip address.










share|improve this question














I have configured many virtualhosts in my current apache2 server, in my local machine (Ubuntu 13.10).



Those are different local sites, with domains which are set in my /etc/hosts:



127.0.0.1       localhost
127.0.0.1 agroplasticos.dev
127.0.0.1 resources.dev
127.0.1.1 luismasuelli-inspiron14

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters


Where the agroplasticos.dev and resources.dev sites were created by me, and the previous settings were set by default.



For localhost, agroplasticos.dev, and resources.dev, I have site entries in /etc/apache2/sites-enabled directory (only those 3 entries exist in this directory), which are links to the corresponding files in /etc/apache2/sites-available:



agroplasticos.dev looks like:



<VirtualHost agroplasticos.dev:80>
ServerName agroplasticos.dev:80
ServerAdmin webmaster@localhost

DocumentRoot /var/www/agroplasticos
<Directory /var/www/agroplasticos>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/agroplasticos-error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/agroplasticos-access.log combined
</VirtualHost>


and resources.dev looks like:



<VirtualHost resources.dev:80>
ServerName resources.dev:80
ServerAdmin webmaster@localhost

DocumentRoot /var/www/resources
<Directory /var/www/resources>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/resources-error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/resources-access.log combined
</VirtualHost>


And -last but not least- localhost looks like this:



<VirtualHost localhost:80>
ServerName localhost:80
ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


What I expect is that if I access such domains, they are resolved to 127.0.0.1 and they are served by apache using the different settings for each site. In particular, resources.dev is just a static files website (it has only images I load externally via http from programs / scripts I'm making), so I don't care about even having PHP for such site. This means: I hit http://resources.dev/mirrorlings/images/sample.png in my browser, and I retrieve an image.



However -and there's the catch- the site is successfully mounted if I have network connection. If i'm not connected, then:




  1. I can access http://localhost/ (the sample, never-modified, "it works" screen appears).

  2. I cannot access http://resources.dev/ (the server did not mount it; http clients like browsers or ActionScript loaders cannot reach such url).

  3. I cannot access http://agroplasticos.dev/ (the server did not mount it; same about http clients).


  4. I'm getting this error log when running sudo service apache2 restart:



    [Sun Jul 20 15:39:55 2014] [error] (111)Connection refused: Could not resolve host name localhost -- ignoring!
    [Sun Jul 20 15:39:55 2014] [error] (111)Connection refused: Could not resolve host name agroplasticos.dev -- ignoring!
    [Sun Jul 20 15:39:55 2014] [warn] The Alias directive in /etc/apache2/conf.d/phpmyadmin.conf at line 3 will probably never match because it overlaps an earlier Alias.
    [Sun Jul 20 15:39:55 2014] [error] (111)Connection refused: Could not resolve host name agroplasticos.dev -- ignoring!
    [Sun Jul 20 15:39:55 2014] [error] (111)Connection refused: Could not resolve host name localhost -- ignoring!
    [Sun Jul 20 15:39:55 2014] [error] (111)Connection refused: Could not resolve host name resources.dev -- ignoring!
    apache2: apr_sockaddr_info_get() failed for luismasuelli-inspiron14
    apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
    [Sun Jul 20 15:39:56 2014] [error] (111)Connection refused: Could not resolve host name localhost -- ignoring!
    [Sun Jul 20 15:39:56 2014] [error] (111)Connection refused: Could not resolve host name agroplasticos.dev -- ignoring!
    [Sun Jul 20 15:39:56 2014] [warn] The Alias directive in /etc/apache2/conf.d/phpmyadmin.conf at line 3 will probably never match because it overlaps an earlier Alias.
    [Sun Jul 20 15:39:56 2014] [error] (111)Connection refused: Could not resolve host name agroplasticos.dev -- ignoring!
    [Sun Jul 20 15:39:56 2014] [error] (111)Connection refused: Could not resolve host name localhost -- ignoring!
    [Sun Jul 20 15:39:56 2014] [error] (111)Connection refused: Could not resolve host name resources.dev -- ignoring!
    apache2: apr_sockaddr_info_get() failed for luismasuelli-inspiron14
    apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName


    Also do not understand why does this log appeared twice. You can see the same line block is repeated with one-second delay.




And my question here: Why do I need to have internet connection when what I want is that Apache resolved such fake domains as local, since they are in /etc/hosts? What do I have to configure in order to allow local, networkless, resolution?



I was trying to develop without having internet connection and could not hit my local servers using local /etc/hosts domain resolution to local (loopback) ip address.







networking apache2 dns hosts






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jul 21 '14 at 3:16









Luis MasuelliLuis Masuelli

2012410




2012410





bumped to the homepage by Community 5 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 5 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.










  • 1





    Have you tried VirtualHost *:80 instead of VirtualHost <fdqn>:80?

    – muru
    Jul 21 '14 at 5:51











  • I'm not in that pc right now. Will that solve it? I thought <fqdn>:80 was like a pattern which was only matched for that file (i.e. I thought that, by doing what you say, every file would match every local domain)

    – Luis Masuelli
    Jul 21 '14 at 21:31













  • that was my impression too, when I was trying to add a host. But no, Apache can use only the request fdqn and the ServerName/ServerAlias values to work. And for me, using fqdns in the virtualhost spec only caused problems.

    – muru
    Jul 22 '14 at 2:04











  • I think the DNS resolver needs to look up the .dev top level domain first, to see what DNS server is authorative for it. Not finding a server for your domains, it falls back to the hosts file.

    – Jos
    Jun 19 '16 at 14:48











  • I think @muru should be right. Try with <VirtualHost *:80> and ServerName agroplasticos.dev. I have explored this case, according to this post: askubuntu.com/q/824086/566421

    – pa4080
    Oct 19 '16 at 17:50














  • 1





    Have you tried VirtualHost *:80 instead of VirtualHost <fdqn>:80?

    – muru
    Jul 21 '14 at 5:51











  • I'm not in that pc right now. Will that solve it? I thought <fqdn>:80 was like a pattern which was only matched for that file (i.e. I thought that, by doing what you say, every file would match every local domain)

    – Luis Masuelli
    Jul 21 '14 at 21:31













  • that was my impression too, when I was trying to add a host. But no, Apache can use only the request fdqn and the ServerName/ServerAlias values to work. And for me, using fqdns in the virtualhost spec only caused problems.

    – muru
    Jul 22 '14 at 2:04











  • I think the DNS resolver needs to look up the .dev top level domain first, to see what DNS server is authorative for it. Not finding a server for your domains, it falls back to the hosts file.

    – Jos
    Jun 19 '16 at 14:48











  • I think @muru should be right. Try with <VirtualHost *:80> and ServerName agroplasticos.dev. I have explored this case, according to this post: askubuntu.com/q/824086/566421

    – pa4080
    Oct 19 '16 at 17:50








1




1





Have you tried VirtualHost *:80 instead of VirtualHost <fdqn>:80?

– muru
Jul 21 '14 at 5:51





Have you tried VirtualHost *:80 instead of VirtualHost <fdqn>:80?

– muru
Jul 21 '14 at 5:51













I'm not in that pc right now. Will that solve it? I thought <fqdn>:80 was like a pattern which was only matched for that file (i.e. I thought that, by doing what you say, every file would match every local domain)

– Luis Masuelli
Jul 21 '14 at 21:31







I'm not in that pc right now. Will that solve it? I thought <fqdn>:80 was like a pattern which was only matched for that file (i.e. I thought that, by doing what you say, every file would match every local domain)

– Luis Masuelli
Jul 21 '14 at 21:31















that was my impression too, when I was trying to add a host. But no, Apache can use only the request fdqn and the ServerName/ServerAlias values to work. And for me, using fqdns in the virtualhost spec only caused problems.

– muru
Jul 22 '14 at 2:04





that was my impression too, when I was trying to add a host. But no, Apache can use only the request fdqn and the ServerName/ServerAlias values to work. And for me, using fqdns in the virtualhost spec only caused problems.

– muru
Jul 22 '14 at 2:04













I think the DNS resolver needs to look up the .dev top level domain first, to see what DNS server is authorative for it. Not finding a server for your domains, it falls back to the hosts file.

– Jos
Jun 19 '16 at 14:48





I think the DNS resolver needs to look up the .dev top level domain first, to see what DNS server is authorative for it. Not finding a server for your domains, it falls back to the hosts file.

– Jos
Jun 19 '16 at 14:48













I think @muru should be right. Try with <VirtualHost *:80> and ServerName agroplasticos.dev. I have explored this case, according to this post: askubuntu.com/q/824086/566421

– pa4080
Oct 19 '16 at 17:50





I think @muru should be right. Try with <VirtualHost *:80> and ServerName agroplasticos.dev. I have explored this case, according to this post: askubuntu.com/q/824086/566421

– pa4080
Oct 19 '16 at 17:50










4 Answers
4






active

oldest

votes


















0














You have to edit the /etc/apache2/apache2.conf file and add your domains in the global configuration section.






share|improve this answer
























  • yeah but those domains do not exist except for what /etc/hosts says, and when I have internet they are resolved. When I don't have internet, they are not resolved. Why the difference?

    – Luis Masuelli
    Jul 21 '14 at 14:09











  • I will try what you say when I'm back home. Currently I don't have that pc here.

    – Luis Masuelli
    Jul 21 '14 at 14:10



















0














Your apache configuration looks okay. And these will work just fine as a fallback if you have an internet connection.



But what you're missing is a local dns resolver, which can transfer your request to a local server, rather than making it resolve at the global internet dns. There is a mini dns server for that called DNSMASQ.



You can configure it to resolve all the .dev domains to your loopback address without consulting with the internet's dns server.



sudo apt-get install dnsmasq


You can find the necessary configuration by looking at its docs.



You have an another option to make it happen via a PAC file. Though I suggest you to stick with dnsmasq as it is much popular and easier to get this done.






share|improve this answer































    0














    It looks like your resolv.conf settings are causing your hosts file to ignored.



    Recent ubuntu's have used resolveconf to manage resolv.conf because its better at working out scenarios where there are multiple connections.



    General resolvconf documentation
    http://manpages.ubuntu.com/manpages/trusty/man8/resolvconf.8.html



    Use the technique in the accepted answer here to regenerate your resolv.conf settings
    How do I get resolvconf to regenerate resolv.conf after I change /etc/network/interfaces?






    share|improve this answer

































      0














      There is another thing to look at - /etc/nsswitch.conf. You can specify the priority of hostname lookups. I have in my nsswitch.conf file the following line:



      hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4


      This is how to interpret it:



      The hosts: line specifies the order in which various name resolution services will be tried. The default is to:




      1. Begin by checking the /etc/Hosts file. If that file provides an IP address for the host name in question, it is used.


      2. Otherwise try mdns4_minimal, which will attempt to resolve the name via multicast DNS only if it ends with .local. If it does but no such mDNS host is located, mdns4_minimal will return NOTFOUND. The default name service switch response to NOTFOUND would be to try the next listed service, but the [NOTFOUND=return] entry overrides that and stops the search with the name unresolved.


      3. Then try the specified DNS servers. This will happen more-or-less immediately if the name does not end in .local, or not at all if it does. If you remove the [NOTFOUND=return] entry, nsswitch would try to locate unresolved .local hosts via unicast DNS. This would generally be a bad thing , as it would send many such requests to Internet DNS servers that would never resolve them. Apparently, that happens a lot.


      4. The final mdns4 entry indicates mDNS will be tried for names that don't end in .local if your specified DNS servers aren't able to resolve them. I thought this was meant to catch mDNS hosts when you don't specifiy the .local TLD, but I just tried it and it doesn't work. Guess I will look into it.



      Source: http://ubuntuforums.org/showthread.php?t=971693



      By changing order in this line you can change the order of how hostnames are resolved. That might explain the fact that localhost cannot be resolved.






      share|improve this answer
























        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "89"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f500472%2fapache-server-not-resolving-by-etc-hosts-if-i-have-not-internet-connection%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        0














        You have to edit the /etc/apache2/apache2.conf file and add your domains in the global configuration section.






        share|improve this answer
























        • yeah but those domains do not exist except for what /etc/hosts says, and when I have internet they are resolved. When I don't have internet, they are not resolved. Why the difference?

          – Luis Masuelli
          Jul 21 '14 at 14:09











        • I will try what you say when I'm back home. Currently I don't have that pc here.

          – Luis Masuelli
          Jul 21 '14 at 14:10
















        0














        You have to edit the /etc/apache2/apache2.conf file and add your domains in the global configuration section.






        share|improve this answer
























        • yeah but those domains do not exist except for what /etc/hosts says, and when I have internet they are resolved. When I don't have internet, they are not resolved. Why the difference?

          – Luis Masuelli
          Jul 21 '14 at 14:09











        • I will try what you say when I'm back home. Currently I don't have that pc here.

          – Luis Masuelli
          Jul 21 '14 at 14:10














        0












        0








        0







        You have to edit the /etc/apache2/apache2.conf file and add your domains in the global configuration section.






        share|improve this answer













        You have to edit the /etc/apache2/apache2.conf file and add your domains in the global configuration section.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 21 '14 at 6:05









        Rajesh RajendranRajesh Rajendran

        767716




        767716













        • yeah but those domains do not exist except for what /etc/hosts says, and when I have internet they are resolved. When I don't have internet, they are not resolved. Why the difference?

          – Luis Masuelli
          Jul 21 '14 at 14:09











        • I will try what you say when I'm back home. Currently I don't have that pc here.

          – Luis Masuelli
          Jul 21 '14 at 14:10



















        • yeah but those domains do not exist except for what /etc/hosts says, and when I have internet they are resolved. When I don't have internet, they are not resolved. Why the difference?

          – Luis Masuelli
          Jul 21 '14 at 14:09











        • I will try what you say when I'm back home. Currently I don't have that pc here.

          – Luis Masuelli
          Jul 21 '14 at 14:10

















        yeah but those domains do not exist except for what /etc/hosts says, and when I have internet they are resolved. When I don't have internet, they are not resolved. Why the difference?

        – Luis Masuelli
        Jul 21 '14 at 14:09





        yeah but those domains do not exist except for what /etc/hosts says, and when I have internet they are resolved. When I don't have internet, they are not resolved. Why the difference?

        – Luis Masuelli
        Jul 21 '14 at 14:09













        I will try what you say when I'm back home. Currently I don't have that pc here.

        – Luis Masuelli
        Jul 21 '14 at 14:10





        I will try what you say when I'm back home. Currently I don't have that pc here.

        – Luis Masuelli
        Jul 21 '14 at 14:10













        0














        Your apache configuration looks okay. And these will work just fine as a fallback if you have an internet connection.



        But what you're missing is a local dns resolver, which can transfer your request to a local server, rather than making it resolve at the global internet dns. There is a mini dns server for that called DNSMASQ.



        You can configure it to resolve all the .dev domains to your loopback address without consulting with the internet's dns server.



        sudo apt-get install dnsmasq


        You can find the necessary configuration by looking at its docs.



        You have an another option to make it happen via a PAC file. Though I suggest you to stick with dnsmasq as it is much popular and easier to get this done.






        share|improve this answer




























          0














          Your apache configuration looks okay. And these will work just fine as a fallback if you have an internet connection.



          But what you're missing is a local dns resolver, which can transfer your request to a local server, rather than making it resolve at the global internet dns. There is a mini dns server for that called DNSMASQ.



          You can configure it to resolve all the .dev domains to your loopback address without consulting with the internet's dns server.



          sudo apt-get install dnsmasq


          You can find the necessary configuration by looking at its docs.



          You have an another option to make it happen via a PAC file. Though I suggest you to stick with dnsmasq as it is much popular and easier to get this done.






          share|improve this answer


























            0












            0








            0







            Your apache configuration looks okay. And these will work just fine as a fallback if you have an internet connection.



            But what you're missing is a local dns resolver, which can transfer your request to a local server, rather than making it resolve at the global internet dns. There is a mini dns server for that called DNSMASQ.



            You can configure it to resolve all the .dev domains to your loopback address without consulting with the internet's dns server.



            sudo apt-get install dnsmasq


            You can find the necessary configuration by looking at its docs.



            You have an another option to make it happen via a PAC file. Though I suggest you to stick with dnsmasq as it is much popular and easier to get this done.






            share|improve this answer













            Your apache configuration looks okay. And these will work just fine as a fallback if you have an internet connection.



            But what you're missing is a local dns resolver, which can transfer your request to a local server, rather than making it resolve at the global internet dns. There is a mini dns server for that called DNSMASQ.



            You can configure it to resolve all the .dev domains to your loopback address without consulting with the internet's dns server.



            sudo apt-get install dnsmasq


            You can find the necessary configuration by looking at its docs.



            You have an another option to make it happen via a PAC file. Though I suggest you to stick with dnsmasq as it is much popular and easier to get this done.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jul 4 '16 at 10:55









            Lokesh DevnaniLokesh Devnani

            11




            11























                0














                It looks like your resolv.conf settings are causing your hosts file to ignored.



                Recent ubuntu's have used resolveconf to manage resolv.conf because its better at working out scenarios where there are multiple connections.



                General resolvconf documentation
                http://manpages.ubuntu.com/manpages/trusty/man8/resolvconf.8.html



                Use the technique in the accepted answer here to regenerate your resolv.conf settings
                How do I get resolvconf to regenerate resolv.conf after I change /etc/network/interfaces?






                share|improve this answer






























                  0














                  It looks like your resolv.conf settings are causing your hosts file to ignored.



                  Recent ubuntu's have used resolveconf to manage resolv.conf because its better at working out scenarios where there are multiple connections.



                  General resolvconf documentation
                  http://manpages.ubuntu.com/manpages/trusty/man8/resolvconf.8.html



                  Use the technique in the accepted answer here to regenerate your resolv.conf settings
                  How do I get resolvconf to regenerate resolv.conf after I change /etc/network/interfaces?






                  share|improve this answer




























                    0












                    0








                    0







                    It looks like your resolv.conf settings are causing your hosts file to ignored.



                    Recent ubuntu's have used resolveconf to manage resolv.conf because its better at working out scenarios where there are multiple connections.



                    General resolvconf documentation
                    http://manpages.ubuntu.com/manpages/trusty/man8/resolvconf.8.html



                    Use the technique in the accepted answer here to regenerate your resolv.conf settings
                    How do I get resolvconf to regenerate resolv.conf after I change /etc/network/interfaces?






                    share|improve this answer















                    It looks like your resolv.conf settings are causing your hosts file to ignored.



                    Recent ubuntu's have used resolveconf to manage resolv.conf because its better at working out scenarios where there are multiple connections.



                    General resolvconf documentation
                    http://manpages.ubuntu.com/manpages/trusty/man8/resolvconf.8.html



                    Use the technique in the accepted answer here to regenerate your resolv.conf settings
                    How do I get resolvconf to regenerate resolv.conf after I change /etc/network/interfaces?







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Apr 13 '17 at 12:24









                    Community

                    1




                    1










                    answered Jul 4 '16 at 11:52









                    AmiasAmias

                    4,3321329




                    4,3321329























                        0














                        There is another thing to look at - /etc/nsswitch.conf. You can specify the priority of hostname lookups. I have in my nsswitch.conf file the following line:



                        hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4


                        This is how to interpret it:



                        The hosts: line specifies the order in which various name resolution services will be tried. The default is to:




                        1. Begin by checking the /etc/Hosts file. If that file provides an IP address for the host name in question, it is used.


                        2. Otherwise try mdns4_minimal, which will attempt to resolve the name via multicast DNS only if it ends with .local. If it does but no such mDNS host is located, mdns4_minimal will return NOTFOUND. The default name service switch response to NOTFOUND would be to try the next listed service, but the [NOTFOUND=return] entry overrides that and stops the search with the name unresolved.


                        3. Then try the specified DNS servers. This will happen more-or-less immediately if the name does not end in .local, or not at all if it does. If you remove the [NOTFOUND=return] entry, nsswitch would try to locate unresolved .local hosts via unicast DNS. This would generally be a bad thing , as it would send many such requests to Internet DNS servers that would never resolve them. Apparently, that happens a lot.


                        4. The final mdns4 entry indicates mDNS will be tried for names that don't end in .local if your specified DNS servers aren't able to resolve them. I thought this was meant to catch mDNS hosts when you don't specifiy the .local TLD, but I just tried it and it doesn't work. Guess I will look into it.



                        Source: http://ubuntuforums.org/showthread.php?t=971693



                        By changing order in this line you can change the order of how hostnames are resolved. That might explain the fact that localhost cannot be resolved.






                        share|improve this answer




























                          0














                          There is another thing to look at - /etc/nsswitch.conf. You can specify the priority of hostname lookups. I have in my nsswitch.conf file the following line:



                          hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4


                          This is how to interpret it:



                          The hosts: line specifies the order in which various name resolution services will be tried. The default is to:




                          1. Begin by checking the /etc/Hosts file. If that file provides an IP address for the host name in question, it is used.


                          2. Otherwise try mdns4_minimal, which will attempt to resolve the name via multicast DNS only if it ends with .local. If it does but no such mDNS host is located, mdns4_minimal will return NOTFOUND. The default name service switch response to NOTFOUND would be to try the next listed service, but the [NOTFOUND=return] entry overrides that and stops the search with the name unresolved.


                          3. Then try the specified DNS servers. This will happen more-or-less immediately if the name does not end in .local, or not at all if it does. If you remove the [NOTFOUND=return] entry, nsswitch would try to locate unresolved .local hosts via unicast DNS. This would generally be a bad thing , as it would send many such requests to Internet DNS servers that would never resolve them. Apparently, that happens a lot.


                          4. The final mdns4 entry indicates mDNS will be tried for names that don't end in .local if your specified DNS servers aren't able to resolve them. I thought this was meant to catch mDNS hosts when you don't specifiy the .local TLD, but I just tried it and it doesn't work. Guess I will look into it.



                          Source: http://ubuntuforums.org/showthread.php?t=971693



                          By changing order in this line you can change the order of how hostnames are resolved. That might explain the fact that localhost cannot be resolved.






                          share|improve this answer


























                            0












                            0








                            0







                            There is another thing to look at - /etc/nsswitch.conf. You can specify the priority of hostname lookups. I have in my nsswitch.conf file the following line:



                            hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4


                            This is how to interpret it:



                            The hosts: line specifies the order in which various name resolution services will be tried. The default is to:




                            1. Begin by checking the /etc/Hosts file. If that file provides an IP address for the host name in question, it is used.


                            2. Otherwise try mdns4_minimal, which will attempt to resolve the name via multicast DNS only if it ends with .local. If it does but no such mDNS host is located, mdns4_minimal will return NOTFOUND. The default name service switch response to NOTFOUND would be to try the next listed service, but the [NOTFOUND=return] entry overrides that and stops the search with the name unresolved.


                            3. Then try the specified DNS servers. This will happen more-or-less immediately if the name does not end in .local, or not at all if it does. If you remove the [NOTFOUND=return] entry, nsswitch would try to locate unresolved .local hosts via unicast DNS. This would generally be a bad thing , as it would send many such requests to Internet DNS servers that would never resolve them. Apparently, that happens a lot.


                            4. The final mdns4 entry indicates mDNS will be tried for names that don't end in .local if your specified DNS servers aren't able to resolve them. I thought this was meant to catch mDNS hosts when you don't specifiy the .local TLD, but I just tried it and it doesn't work. Guess I will look into it.



                            Source: http://ubuntuforums.org/showthread.php?t=971693



                            By changing order in this line you can change the order of how hostnames are resolved. That might explain the fact that localhost cannot be resolved.






                            share|improve this answer













                            There is another thing to look at - /etc/nsswitch.conf. You can specify the priority of hostname lookups. I have in my nsswitch.conf file the following line:



                            hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4


                            This is how to interpret it:



                            The hosts: line specifies the order in which various name resolution services will be tried. The default is to:




                            1. Begin by checking the /etc/Hosts file. If that file provides an IP address for the host name in question, it is used.


                            2. Otherwise try mdns4_minimal, which will attempt to resolve the name via multicast DNS only if it ends with .local. If it does but no such mDNS host is located, mdns4_minimal will return NOTFOUND. The default name service switch response to NOTFOUND would be to try the next listed service, but the [NOTFOUND=return] entry overrides that and stops the search with the name unresolved.


                            3. Then try the specified DNS servers. This will happen more-or-less immediately if the name does not end in .local, or not at all if it does. If you remove the [NOTFOUND=return] entry, nsswitch would try to locate unresolved .local hosts via unicast DNS. This would generally be a bad thing , as it would send many such requests to Internet DNS servers that would never resolve them. Apparently, that happens a lot.


                            4. The final mdns4 entry indicates mDNS will be tried for names that don't end in .local if your specified DNS servers aren't able to resolve them. I thought this was meant to catch mDNS hosts when you don't specifiy the .local TLD, but I just tried it and it doesn't work. Guess I will look into it.



                            Source: http://ubuntuforums.org/showthread.php?t=971693



                            By changing order in this line you can change the order of how hostnames are resolved. That might explain the fact that localhost cannot be resolved.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jul 4 '16 at 12:05









                            nobodynobody

                            3,2921013




                            3,2921013






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Ask Ubuntu!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f500472%2fapache-server-not-resolving-by-etc-hosts-if-i-have-not-internet-connection%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                GameSpot

                                connect to host localhost port 22: Connection refused

                                Getting a Wifi WPA2 wifi connection