Temporary failure resolving 'archive.ubuntu.com' from apt-get update means the machine could not turn the mirror's name into an address: the DNS server in /etc/resolv.conf did not answer. Put a working nameserver line back in that file and the update succeeds.

Check the file first with cat /etc/resolv.conf. In the test it held one unreachable address; restoring the original file fixed apt-get and curl at once. This test covers a resolv.conf whose nameserver does not answer; how WSL writes this file was not tested here.

The error

time apt-get update
Ign:1 http://archive.ubuntu.com/ubuntu noble InRelease
...
Err:2 http://security.ubuntu.com/ubuntu noble-security InRelease
  Temporary failure resolving 'security.ubuntu.com'
...
Err:1 http://archive.ubuntu.com/ubuntu noble InRelease
  Temporary failure resolving 'archive.ubuntu.com'
...
Reading package lists...
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/noble/InRelease  Temporary failure resolving 'archive.ubuntu.com'
...
W: Some index files failed to download. They have been ignored, or old ones used instead.

real	4m0.904s
...
exit code: 0

The same broken file made curl fail after ten seconds:

time curl -sS -o /dev/null https://archive.ubuntu.com/
curl: (6) Could not resolve host: archive.ubuntu.com

real	0m10.022s
...
exit code: 6

Why it happens

/etc/resolv.conf contained a single line, nameserver 203.0.113.1, an address where nothing answers. The lookups failed: getent hosts archive.ubuntu.com printed nothing and returned 2, curl returned 6 after ten seconds, and apt-get took four minutes before it printed the W: Failed to fetch lines.

Watch the exit code: apt-get update returned 0 even though no index was downloaded. A script that checks only the exit code carries on as if the update had worked. Read the Err: and W: lines, not only the exit code.

The fix

cp /tmp/resolv.bak /etc/resolv.conf
cat /etc/resolv.conf
# Generated by Docker Engine.
...
nameserver 192.168.65.7
...
getent hosts archive.ubuntu.com
91.189.90.11    archive.ubuntu.com
...
apt-get update
Hit:1 http://security.ubuntu.com/ubuntu noble-security InRelease
Hit:2 http://archive.ubuntu.com/ubuntu noble InRelease
Hit:3 http://archive.ubuntu.com/ubuntu noble-updates InRelease
Hit:4 http://archive.ubuntu.com/ubuntu noble-backports InRelease
Reading package lists...
exit code: 0

The fix was to put back the file that held a reachable DNS server; after that getent returned addresses and the update showed four Hit: lines. In the container that server was Docker's own resolver at 192.168.65.7. On your machine the right address is the one your network provides, so restore the file you had before the change rather than copying this address. Test with getent hosts archive.ubuntu.com before running apt-get again: in the test it printed nothing with the broken file and the mirror's addresses with the working one.

How it was reproduced

The capture was made in an ubuntu:24.04 container (Ubuntu 24.04.5 LTS, apt 2.8.3, curl 8.5.0, Docker Engine 29.9.2) standing in for Ubuntu in WSL. The script copied /etc/resolv.conf aside, overwrote it with nameserver 203.0.113.1 (a documentation address that does not answer), ran curl, getent and apt-get update, then copied the original back and ran the same lookups again. The literal phrase "Temporary failure in name resolution" did not appear in this capture; apt-get and curl printed the messages above.

Frequently asked

How do I fix Temporary failure resolving archive.ubuntu.com?
Check /etc/resolv.conf with cat. In the test it held an unreachable nameserver; restoring the previous file made getent return addresses and apt-get update showed Hit lines for all four sources.
Why does apt-get update return exit code 0 when it fails to fetch?
In the test apt-get update printed Err and W: Failed to fetch lines for every source and still returned 0, so a script must read those lines rather than rely on the exit code.
How do I test DNS in Ubuntu without apt-get?
Run getent hosts archive.ubuntu.com. With the broken resolv.conf it printed nothing and returned 2; with the working file it printed the mirror's addresses.

More decoded errors in the Fixes category. If the update works but a package is still missing, see E: Unable to locate package.