WSL2 apt update not working

I have recently set up Windows Subsystem for Linux (WSL2) on my Windows 10 laptop and installed Ubuntu 20.04 LTS. When i tried ‘apt update’ on Ubuntu distro, it failed with following error messages.

> sudo apt-get update
Err:1 bionic-security InRelease
  Temporary failure resolving ''
Err:2 bionic InRelease
  Temporary failure resolving ''
Err:3 bionic-updates InRelease
  Temporary failure resolving ''
Err:4 bionic-backports InRelease
  Temporary failure resolving ''

I did the following to get it working.

Step #1.

On the Ubuntu distro, create a file at this location /etc/wsl.conf.

The file should have the following configuration.

generateResolvConf = false

If we don’t set this file, WSL will automatically load a default /etc/resolv.conf with default namesever configuration.

Shut down and restart the distro.

Step #2

Delete the default /etc/resolv.conf file.

sudo rm /etc/resolv.conf

Create a new /etc/resolv.conf with the following entry.


Now, restart the WSL2 and open the distro again. The apt update on WSL2 should work like a charm.

4 thoughts on “WSL2 apt update not working

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.