The Symptom
You’re pinging localhost or a custom hostname you added to /etc/hosts and the request hangs or returns “Name or service not known”. The same name resolves fine on another machine, and dig or nslookup against a public DNS server works. The problem is isolated to the local resolver. In most modern distributions this points to a mis‑configured systemd‑resolved service or a stale cache.
Why systemd‑resolved Matters
systemd‑resolved is the default name‑resolution daemon on Fedora, Debian, Ubuntu, Arch, and many other distros since 2015. It replaces the older dnsmasq‑based /etc/resolv.conf approach and offers: