Search code examples
ubuntuhostname

Failed to start hostname.service: Unit hostname.service is masked


Failed to start hostname.service: Unit hostname.service is masked.

This happened after hostname update, tried to do a sudo service hostname start.


Solution

  • This happens when there is a mismatch in hostname which causes the system to fail the lookup of the hostname.

    Make sure these files are in-order and reflect proper entry for your new hostname

    1. /etc/hostname
    2. /etc/hosts

    say your older hostname is: hostname.old and the new one is hostname.new

    then /etc/hostname should be as following

    hostname.new
    

    and /etc/hosts should contain an entry as follows:

    ...
    127.0.0.1    hostname.new
    ...