Fixing Temporary Failure in Name Resolution on WSL Ubuntu

In Guides by Bintoro Adi Guna1 Comment


Anda berbicara Bahasa Indonesia? Baca artikel terjemahannya di sini!

WSL is the perfect compromise in the debate between Windows and UNIX (MacOS or Linux) for programming needs. Windows is perfect for gaming, but kind of sucks for programming (depends on which platform you’re developing for). On the other hand, UNIX is perfect for programming (most tools are available first on UNIX), but sucks hard at gaming and apps. WSL, in the meantime, is probably the best of both worlds. It allows you to run a full-fledge Linux right within Windows.

However, WSL isn’t perfect. It’s still under development and there are some annoying issues. One of which is being unable to connect to the Internet. To be exact, the error I got was Temporary Failure in Name Resolution, and I’m using Ubuntu for WSL. In this article, I’m going to share how to resolve this issue.

This error prevents your WSL from connecting to the Internet

Well, let’s get to it.

1. Create a Resolver File

Create a file called resolv.conf in /etc/ directory. Basically we’re going to tell WSL to resolve domain name request to the nameserver written inside this file.

2. Set Your Nameserver

Open the file, and write the following line:


What this line does is telling WSL to use (or Google’s DNS) as DNS server for resolving domain names. You can replace it to any other DNS server that you want.

Don’t forget to save the file after you’re done.

3. Lock the File

By now, your WSL should be able to connect to the Internet. However, depending on your system’s configuration, the resolver file might be deleted during WSL startup. At least, that’s what I experienced. Therefore, I recommend making the file to be immutable by running the following command:

sudo chattr +i /etc/resolv.conf

What that code does what adding a new attribute called immutable (hence the i) to the resolver file. Immutable means that the file cannot be changed, including deleted and moved.

4. Test Your Connection

Now, do something that needs Internet connection like updating apps, or just pinging a website. It should work. You can also try restarting WSL to see if your Internet still works afterwards.

After this, hopefully your Internet connection is restored


Not too difficult, right? Congratulations, now your WSL is able to connect to the Internet. I hope this tip is useful for you. If you have any other tips or questions, as usual, don’t hesitate to sound them off in the comments section below. Finally, as usual, thanks for reading and see you in the next article! 😀

Leave a Comment