Fix apt that will not update
We'll confirm the error, check network and DNS, verify sources.list, fix repository URLs, and resolve lock issues so apt update succeeds.
What you'll need
- SSH or shell access with sudo
- Root or sudo privileges
Step-by-step diagnostic
Quick triage — pick your path
Quick triage — pick your path
Choose the option that matches what you see. You can jump straight to that section.
Show full guide
Steps
Goal: Confirm the error, check network and DNS, verify sources.list, then fix repository or lock issues.
- Run
sudo apt updateand capture the full output. Common errors: “Could not resolve” (DNS/network), “404 Not Found” (bad repository URL), “Unable to acquire the dpkg frontend lock” (another process or stale lock). - Good: You have the error. Proceed to Check network or Verify sources.list based on the error.
Check network
Goal: Rule out network and DNS as causes of apt update failure.
- Run
ping -c 3 archive.ubuntu.com(Ubuntu) orping -c 3 deb.debian.org(Debian). If ping fails, checkip routeandip addrfor interface state. - Run
getent hosts archive.ubuntu.comornslookup archive.ubuntu.com. If resolution fails, check /etc/resolv.conf for valid nameservers. - Good: Ping and DNS work—check sources.list and proxy. Bad: Fix network or DNS before retrying apt.
Verify sources.list
Goal: Confirm repository URLs and release names are correct.
- Check /etc/apt/sources.list and files in /etc/apt/sources.list.d/. Look for typos in URLs, wrong release codenames (e.g. jammy for Ubuntu 22.04), or disabled lines.
- Run
lsb_release -csto get the correct codename. Update any line that uses a wrong codename. - Good: Entries are valid. Retry apt update. Bad: Fix or comment out invalid entries.
Fix repository 404
Goal: Correct a repository URL or release name that causes 404.
- When apt reports “404 Not Found” for a repository, the URL or release name is wrong. Check your release with
lsb_release -cs. - Update the sources.list line to use the correct codename and mirror. Comment out third-party repos that no longer exist.
- Retry
sudo apt update. Confirm the repository succeeds.
Resolve lock
Goal: Clear a stale dpkg lock or wait for a running apt process.
- Run
ps aux | grep -E "apt|dpkg"to find running processes. If a legitimate process is running, wait for it to finish. - If a process crashed, run
sudo rm /var/lib/dpkg/lock-frontend /var/lib/dpkg/lockandsudo dpkg --configure -a. Retry apt update.
Check proxy and firewall
Goal: Confirm proxy and firewall are not blocking apt.
- When the server uses a proxy, set http_proxy and https_proxy or configure in /etc/apt/apt.conf.d/.
- Confirm the firewall allows outbound HTTPS (443) to the repository hosts.
When to escalate
- The repository mirror may be down—try a different mirror in sources.list.
- Corporate proxy or custom repo—when to call a pro or contact your administrator.
Verification
sudo apt updatecompletes without error.- Output shows “Reading package lists… Done” and either “All packages are up to date” or a list of upgradable packages.
- No “Could not resolve”, “404”, or lock errors.
Escalation ladder
Work from the device outward. Stop when the problem is fixed.
- Confirm error Run apt update and capture the exact error message.
- Network and DNS Check connectivity and DNS; fix if broken.
- sources.list Verify repository URLs and release names; fix 404s.
- Lock and proxy Resolve dpkg lock; check proxy and firewall.
- Escalate Mirror down or custom repo—try different mirror or contact administrator.
What to capture if you need help
Before calling support or posting for help, have these ready. It speeds everything up.
- Full apt update output
- Output of ping and getent/nslookup
- Contents of /etc/apt/sources.list and sources.list.d/
- Output of lsb_release -cs
- Steps already tried
Does the error mention network or resolve?
Errors like "Could not resolve" or "Temporary failure resolving" point to network or DNS.
You can change your answer later.
Can you ping the repository host?
Test connectivity to archive.ubuntu.com or deb.debian.org.
You can change your answer later.
Does DNS resolve the repository host?
Run getent hosts archive.ubuntu.com or nslookup.
You can change your answer later.
Fix network and retry
Fix DNS and retry
Is it a 404 or a lock error?
404 = bad repository URL. Lock = another apt/dpkg process or stale lock.
You can change your answer later.
Fix sources.list and retry
Resolve lock and retry
Are sources.list entries correct?
404 or repository errors mean wrong URL or release.
Reviewed by Blackbox Atlas
Rate this guide
Was this helpful?
Thanks for your feedback.