Linux – Unable to resolve host name in WSL

windows-subsystem-for-linux

In almost any action I do in Windows Subsystem for Linux, I get a notification "How to resolve host name". Why would this happen in each fresh install and how to solve it?

Best Answer

I don't know why it happens (please improve the answer with an explanation), here is a working solution for this problem:

1. Execute:

nano /etc/hostname

Type your machine name in capital letters ( it would be something like DESKTOP-SOMETHING). Delete anything besides your machine name.

Save and exit.

2. Then, execute:

nano /etc/hosts

Then, Make sure the file's first two rows looks as follows:

  127.0.0.1 localhost.localdomain localhost
  127.0.1.1 DESKTOP-SOMETHING

Save and exit.

Related Question