Fix sudo on Windows 10 Linux Subsystem Cannot Resolve Local Machine Name

windows 10windows-10-v1607windows-subsystem-for-linux

I installed Windows 10 Anniversary update and the Linux subsystem. When running anything with sudo it takes ages and then I get this error message:

sudo: unable to resolve host MYMACHINE

How to get rid of this and make sudo fast?

Best Answer

You have to edit /etc/hosts while superuser and add your machine name after the first line with localhost

127.0.0.1        localhost MYMACHINE

This will make the system not try to resolve the hostname from DNS.