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

warlockdead picture warlockdead · Feb 14, 2018 · Viewed 26.3k times · Source

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

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

Answer

Thusitha Sumanadasa picture Thusitha Sumanadasa · Jul 9, 2018

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.