Apt Update Not Working on Windows Subsystem for Linux [SOLVED]

Published: 2021 December 07

system administration Windows OS Windows Subsystem for Linux technical troubleshooting technical troubleshooting - solved

The Problem

In Windows Subsystem for Linux (WSL) when running the command

sudo apt update

the following error appears for every package

“Temporary failure resolving ‘archive.ubuntu.com’”

and nothing is updated.

Furthermore, nothing can be installed using the command

sudo apt install <<PACKAGE-NAME>>

for the same reason.

The Process

A web search for the error led to a StackExchange question discussing the issue, which offered guidance on the problem.

The Solution

Temporary Solution

As this StackExchange answer points out, updating /etc/resolv.conf by editing the nameserver line to

nameserver 8.8.8.8

resolves the issue, at least until WSL is restarted.

Durable Solution

As this other StackExchange answer points out, to make the solution more durable, some additional steps are required.

  1. Create the file /etc/wsl.conf.
  2. Add the following to it and save.
[network]
generateResolvConf = false
  1. Shutdown WSL by opening a cmd terminal and running the following.
wsl --shutdown
  1. Restart WSL.
  2. If it exists, delete the /etc/resolv.conf because it’s most likely a link to another file.
  3. Create a new /etc/resolv.conf file.
  4. Add the following to it and save.
nameserver 8.8.8.8

The apt update and apt install processes (as well as other processes that need network name resolution) should now work.

Copying Directory Structure With a Bash Script - With Help From ChatGPT AI

Published: 2024 January 22

Setting Up a Raspberry Pi as a Linux Print Server with CUPS

Published: 2024 January 19

Setting Up a Raspberry Pi Zero 2 W with Ubuntu Server

Published: 2024 January 04