You could install libnss-myhostname (provided by systemd) instead of adding the hostname to /etc/hosts. libnss-myhostname takes care of mapping the local hostname to 127.0.0.1, so that listing the hostname explicitly in /etc/hosts is not necessary. See https://github.com/systemd/systemd/issues/12793 for more.
Ubuntu does not ship libnss-myhostname by default, so I see why one would end up adding their hostname to /etc/hosts manually. But, from the upstream perspective, it is not necessary for systemd-hostnamed to modify /etc/hosts, so I don't think there is anything to do here. ** Bug watch added: github.com/systemd/systemd/issues #12793 https://github.com/systemd/systemd/issues/12793 ** Changed in: systemd (Ubuntu) Status: New => Won't Fix -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/2067333 Title: hostnamectl --set-hostname doesn't update /etc/hosts To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/2067333/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs