Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 481
warlockdead Avatar asked Feb 14 '18 07:02

warlockdead


3 Answers

Update the hostname in both /etc/hostname file and /etc/hosts file before running service hostname restart.

On newer systems running systemd (e.g. Ubuntu 16.04), have to use:

sudo hostnamectl set-hostname new-host-name . In here, edit new-host-name with your host name.

like image 176
Thusitha Sumanadasa Avatar answered Nov 16 '22 13:11

Thusitha Sumanadasa


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
...
like image 40
anand Avatar answered Nov 16 '22 12:11

anand


Nothing to worry about. I've got the same problem when I tried to rename my computer name (hostname) in :

  • /etc/hostname
  • /etc/hosts

after editing both files, the command sudo service hostname restart returned the same error.

I simply rebooted my computer and the saw the computer name (hostname) has been successfully changed. Just reboot your machine and you'll be fine.

like image 37
smerllo Avatar answered Nov 16 '22 11:11

smerllo