Editing /etc/hosts causes Apache server block to be missed

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
0
down vote

favorite












In order to fix some email (SPF) issues, I changed my Ubuntu VPS hostname to its FQDN in /etc/hosts and /etc/hostname. However, now, when I hit the URL in a browser I get a 404 from Apache instead of triggering the block in /etc/apache2/sites-available/example.com which would redirect to the www version of the site. Typing www.example.com still works.



My hosts file now looks like this:

127.0.0.1 localhost
256.256.256.256 example.com # I am using a real IP and FQDN, obviously



I don't know enough about it to know why Apache is serving up a 404. It says The requested URL / cannot be found on this server and nothing else. Why did editing my hosts file cause this?










share|improve this question





















  • I deleted the entry in /etc/hosts with the IP and domain and it's still happening - could it actually be /etc/hostname that is causing the issue?
    – armadadrive
    Feb 5 at 21:33










  • Figured it out - 000-default.conf is actually enabled and needs to be updated, whereas I never paid it any attention before since everything "just worked".
    – armadadrive
    Feb 5 at 21:50










  • Don't put the FQDN in your /etc/hosts or /etc/hostname - this should just be the locally known hostname for your machine, otherwise a few things will work weirdly. Also, what is in there is not related to your Apache setup or how people on the internet find your machine.
    – thomasrutter
    Feb 5 at 22:45











  • If I didn't do that then mail sent from that machine was failing SPF because the machine was sending as mymachinename.local in mail headers I examined.
    – armadadrive
    Feb 5 at 22:56










  • You need to configure the mail hostname in your MTA, eg myhostname in postfix. Set this to a FQDN, or set it to a blank string and set mydomain and it'll automatically determine the FQDN. No need to change /etc/hostname or /etc/hosts to something non-standard just to try and influence one service because what's in those files can effect other things on the system.
    – thomasrutter
    Feb 6 at 1:52















up vote
0
down vote

favorite












In order to fix some email (SPF) issues, I changed my Ubuntu VPS hostname to its FQDN in /etc/hosts and /etc/hostname. However, now, when I hit the URL in a browser I get a 404 from Apache instead of triggering the block in /etc/apache2/sites-available/example.com which would redirect to the www version of the site. Typing www.example.com still works.



My hosts file now looks like this:

127.0.0.1 localhost
256.256.256.256 example.com # I am using a real IP and FQDN, obviously



I don't know enough about it to know why Apache is serving up a 404. It says The requested URL / cannot be found on this server and nothing else. Why did editing my hosts file cause this?










share|improve this question





















  • I deleted the entry in /etc/hosts with the IP and domain and it's still happening - could it actually be /etc/hostname that is causing the issue?
    – armadadrive
    Feb 5 at 21:33










  • Figured it out - 000-default.conf is actually enabled and needs to be updated, whereas I never paid it any attention before since everything "just worked".
    – armadadrive
    Feb 5 at 21:50










  • Don't put the FQDN in your /etc/hosts or /etc/hostname - this should just be the locally known hostname for your machine, otherwise a few things will work weirdly. Also, what is in there is not related to your Apache setup or how people on the internet find your machine.
    – thomasrutter
    Feb 5 at 22:45











  • If I didn't do that then mail sent from that machine was failing SPF because the machine was sending as mymachinename.local in mail headers I examined.
    – armadadrive
    Feb 5 at 22:56










  • You need to configure the mail hostname in your MTA, eg myhostname in postfix. Set this to a FQDN, or set it to a blank string and set mydomain and it'll automatically determine the FQDN. No need to change /etc/hostname or /etc/hosts to something non-standard just to try and influence one service because what's in those files can effect other things on the system.
    – thomasrutter
    Feb 6 at 1:52













up vote
0
down vote

favorite









up vote
0
down vote

favorite











In order to fix some email (SPF) issues, I changed my Ubuntu VPS hostname to its FQDN in /etc/hosts and /etc/hostname. However, now, when I hit the URL in a browser I get a 404 from Apache instead of triggering the block in /etc/apache2/sites-available/example.com which would redirect to the www version of the site. Typing www.example.com still works.



My hosts file now looks like this:

127.0.0.1 localhost
256.256.256.256 example.com # I am using a real IP and FQDN, obviously



I don't know enough about it to know why Apache is serving up a 404. It says The requested URL / cannot be found on this server and nothing else. Why did editing my hosts file cause this?










share|improve this question













In order to fix some email (SPF) issues, I changed my Ubuntu VPS hostname to its FQDN in /etc/hosts and /etc/hostname. However, now, when I hit the URL in a browser I get a 404 from Apache instead of triggering the block in /etc/apache2/sites-available/example.com which would redirect to the www version of the site. Typing www.example.com still works.



My hosts file now looks like this:

127.0.0.1 localhost
256.256.256.256 example.com # I am using a real IP and FQDN, obviously



I don't know enough about it to know why Apache is serving up a 404. It says The requested URL / cannot be found on this server and nothing else. Why did editing my hosts file cause this?







apache2 hosts






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 5 at 21:22









armadadrive

61857




61857











  • I deleted the entry in /etc/hosts with the IP and domain and it's still happening - could it actually be /etc/hostname that is causing the issue?
    – armadadrive
    Feb 5 at 21:33










  • Figured it out - 000-default.conf is actually enabled and needs to be updated, whereas I never paid it any attention before since everything "just worked".
    – armadadrive
    Feb 5 at 21:50










  • Don't put the FQDN in your /etc/hosts or /etc/hostname - this should just be the locally known hostname for your machine, otherwise a few things will work weirdly. Also, what is in there is not related to your Apache setup or how people on the internet find your machine.
    – thomasrutter
    Feb 5 at 22:45











  • If I didn't do that then mail sent from that machine was failing SPF because the machine was sending as mymachinename.local in mail headers I examined.
    – armadadrive
    Feb 5 at 22:56










  • You need to configure the mail hostname in your MTA, eg myhostname in postfix. Set this to a FQDN, or set it to a blank string and set mydomain and it'll automatically determine the FQDN. No need to change /etc/hostname or /etc/hosts to something non-standard just to try and influence one service because what's in those files can effect other things on the system.
    – thomasrutter
    Feb 6 at 1:52

















  • I deleted the entry in /etc/hosts with the IP and domain and it's still happening - could it actually be /etc/hostname that is causing the issue?
    – armadadrive
    Feb 5 at 21:33










  • Figured it out - 000-default.conf is actually enabled and needs to be updated, whereas I never paid it any attention before since everything "just worked".
    – armadadrive
    Feb 5 at 21:50










  • Don't put the FQDN in your /etc/hosts or /etc/hostname - this should just be the locally known hostname for your machine, otherwise a few things will work weirdly. Also, what is in there is not related to your Apache setup or how people on the internet find your machine.
    – thomasrutter
    Feb 5 at 22:45











  • If I didn't do that then mail sent from that machine was failing SPF because the machine was sending as mymachinename.local in mail headers I examined.
    – armadadrive
    Feb 5 at 22:56










  • You need to configure the mail hostname in your MTA, eg myhostname in postfix. Set this to a FQDN, or set it to a blank string and set mydomain and it'll automatically determine the FQDN. No need to change /etc/hostname or /etc/hosts to something non-standard just to try and influence one service because what's in those files can effect other things on the system.
    – thomasrutter
    Feb 6 at 1:52
















I deleted the entry in /etc/hosts with the IP and domain and it's still happening - could it actually be /etc/hostname that is causing the issue?
– armadadrive
Feb 5 at 21:33




I deleted the entry in /etc/hosts with the IP and domain and it's still happening - could it actually be /etc/hostname that is causing the issue?
– armadadrive
Feb 5 at 21:33












Figured it out - 000-default.conf is actually enabled and needs to be updated, whereas I never paid it any attention before since everything "just worked".
– armadadrive
Feb 5 at 21:50




Figured it out - 000-default.conf is actually enabled and needs to be updated, whereas I never paid it any attention before since everything "just worked".
– armadadrive
Feb 5 at 21:50












Don't put the FQDN in your /etc/hosts or /etc/hostname - this should just be the locally known hostname for your machine, otherwise a few things will work weirdly. Also, what is in there is not related to your Apache setup or how people on the internet find your machine.
– thomasrutter
Feb 5 at 22:45





Don't put the FQDN in your /etc/hosts or /etc/hostname - this should just be the locally known hostname for your machine, otherwise a few things will work weirdly. Also, what is in there is not related to your Apache setup or how people on the internet find your machine.
– thomasrutter
Feb 5 at 22:45













If I didn't do that then mail sent from that machine was failing SPF because the machine was sending as mymachinename.local in mail headers I examined.
– armadadrive
Feb 5 at 22:56




If I didn't do that then mail sent from that machine was failing SPF because the machine was sending as mymachinename.local in mail headers I examined.
– armadadrive
Feb 5 at 22:56












You need to configure the mail hostname in your MTA, eg myhostname in postfix. Set this to a FQDN, or set it to a blank string and set mydomain and it'll automatically determine the FQDN. No need to change /etc/hostname or /etc/hosts to something non-standard just to try and influence one service because what's in those files can effect other things on the system.
– thomasrutter
Feb 6 at 1:52





You need to configure the mail hostname in your MTA, eg myhostname in postfix. Set this to a FQDN, or set it to a blank string and set mydomain and it'll automatically determine the FQDN. No need to change /etc/hostname or /etc/hosts to something non-standard just to try and influence one service because what's in those files can effect other things on the system.
– thomasrutter
Feb 6 at 1:52











1 Answer
1






active

oldest

votes

















up vote
0
down vote













The issue is actually in the default Apache configuration file (/etc/apache2/sites-available/000-default.conf).



Uncomment the line:



#ServerName example.com and add your server's FQDN (fully qualified domain name).



Finally, run sudo service apache2 reload to have Apache pickup on the config file change.






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',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    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%2f1003369%2fediting-etc-hosts-causes-apache-server-block-to-be-missed%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    The issue is actually in the default Apache configuration file (/etc/apache2/sites-available/000-default.conf).



    Uncomment the line:



    #ServerName example.com and add your server's FQDN (fully qualified domain name).



    Finally, run sudo service apache2 reload to have Apache pickup on the config file change.






    share|improve this answer
























      up vote
      0
      down vote













      The issue is actually in the default Apache configuration file (/etc/apache2/sites-available/000-default.conf).



      Uncomment the line:



      #ServerName example.com and add your server's FQDN (fully qualified domain name).



      Finally, run sudo service apache2 reload to have Apache pickup on the config file change.






      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        The issue is actually in the default Apache configuration file (/etc/apache2/sites-available/000-default.conf).



        Uncomment the line:



        #ServerName example.com and add your server's FQDN (fully qualified domain name).



        Finally, run sudo service apache2 reload to have Apache pickup on the config file change.






        share|improve this answer












        The issue is actually in the default Apache configuration file (/etc/apache2/sites-available/000-default.conf).



        Uncomment the line:



        #ServerName example.com and add your server's FQDN (fully qualified domain name).



        Finally, run sudo service apache2 reload to have Apache pickup on the config file change.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 5 at 21:49









        armadadrive

        61857




        61857



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1003369%2fediting-etc-hosts-causes-apache-server-block-to-be-missed%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            pylint3 and pip3 broken

            Missing snmpget and snmpwalk

            How to enroll fingerprints to Ubuntu 17.10 with VFS491