A Linux server may cache name lookups through systemd-resolved, NSCD or another resolver. Clear the cache used by the server rather than installing a new service just to run a flush command.

Identify the active resolver

Check the server’s resolver configuration and active services. These checks can help on a systemd-based installation:

systemctl is-active systemd-resolved
systemctl is-active nscd

An inactive service has no active cache to clear through its command. Applications can also maintain their own caches.

systemd-resolved

If the server uses it, run:

sudo resolvectl flush-caches

NSCD

If the server already uses NSCD for host lookups, invalidate that cache:

sudo nscd -i hosts

This targets host records rather than restarting every NSCD cache. Check the service’s local documentation if a different version uses other options.

Verify the lookup

Retry the intended lookup, for example:

getent hosts example.com

Replace example.com with the affected hostname. A hosts-file entry or upstream cached DNS answer can still determine the result; a local flush does not change public DNS.