sudo: unable to resolve host
sudo tries to resolve the machine's own hostname and cannot, so every invocation pauses and warns. It still works — it is just slow and noisy.
What you see
Every sudo command prints "sudo: unable to resolve host myserver" and often takes several seconds before running.
What is actually wrong
The hostname was changed without updating /etc/hosts, so the name in /etc/hostname has no entry mapping it to a loopback address.
Codes and articles
The fix
Map the hostname to loopback
Any time this warning appears. It is a one-line fix.
Find out what the machine thinks it is called.
hostnamehostnamectl statuscat /etc/hostname
Look at what /etc/hosts currently says.
cat /etc/hostsAdd the name to the loopback line. Keep localhost first — order matters to some resolvers.
sudo sed -i "s/^127.0.1.1.*/127.0.1.1\t$(hostname)/" /etc/hosts || echo "127.0.1.1\t$(hostname)" | sudo tee -a /etc/hostsDebian and Ubuntu use 127.0.1.1 for the machine's own name specifically so it is distinct from localhost. RHEL-family conventionally appends it to the 127.0.0.1 line instead.
Confirm it resolves now.
getent hosts $(hostname)If the hostname itself is wrong, set it properly rather than editing files by hand.
sudo hostnamectl set-hostname myserver.example.com
time sudo trueRelated faults
Where this stops. This write-up was written and checked by hand. It says what each step changes, how to confirm it worked and how to reverse it, and anything destructive is flagged before you reach it. If it does not match what your machine is doing, search the Support Centre for the exact code or message — and when something needs a person, get in touch.