How to Fix apt-get update Stuck in Ubuntu

Maintaining an updated Linux system is critical for security and stability, which is why apt-get update is often the very first command run on a new Ubuntu server or desktop. However, the process occasionally gets completely stuck, usually hanging indefinitely at “0% [Connecting to archive.ubuntu.com]” or stalling on “Waiting for headers.”

When the Advanced Package Tool (APT) hangs, it prevents you from installing new software or receiving security patches. This issue is almost always caused by a failing repository mirror, corrupted local cache, or an IPv6 routing issue.

Here is exactly how to troubleshoot and fix an apt-get update process that is stuck in Ubuntu.

1. Abort the Frozen Process

Before you can fix the issue, you must stop the process that is currently hanging.

  1. Click into your terminal window.
  2. Press Ctrl + C on your keyboard. This sends a SIGINT (interrupt signal) to forcefully terminate the hung apt-get command.

If Ctrl + C does not work, open a second terminal session and kill the process manually:

sudo killall apt apt-get

2. Clear the Corrupted APT Cache

The most common reason for a stalled update is a corrupted local package list. When APT attempts to merge new server data with corrupted local data, it can freeze.

You can force Ubuntu to completely rebuild these lists from scratch by deleting the current cache.

  1. Clean the downloaded package archive:
    sudo apt-get clean
  2. Move the existing lists to a backup folder (this is safer than deleting them outright):
    sudo mv /var/lib/apt/lists /var/lib/apt/lists.old
  3. Recreate the required directory structure:
    sudo mkdir -p /var/lib/apt/lists/partial
  4. Attempt the update again:
    sudo apt-get update

3. Force IPv4 Resolution (The “Waiting for Headers” Fix)

Ubuntu sometimes defaults to IPv6 when connecting to the official software repositories. If your ISP, local router, or VPN does not perfectly support IPv6 routing, the connection will hang indefinitely while waiting for a response that will never arrive.

You can test if this is the problem by forcing APT to use the older, more reliable IPv4 standard for a single command:

sudo apt-get -o Acquire::ForceIPv4=true update

If the update succeeds instantly, IPv6 is your culprit. You can make this fix permanent by creating an APT configuration file:

  1. Create a new configuration file:
    sudo nano /etc/apt/apt.conf.d/99force-ipv4
  2. Add the following line to the file:
    Acquire::ForceIPv4 "true";
  3. Save and exit (Press Ctrl + O, Enter, then Ctrl + X).

4. Switch to a Better Repository Mirror

If you are still stuck at “0% [Connecting to…]”, the specific server you are trying to download from might be offline or experiencing heavy load. Switching to a different regional mirror will bypass the broken server.

For Ubuntu Desktop (GUI)

  1. Open the application menu and search for Software & Updates.
  2. Under the “Ubuntu Software” tab, find the Download from: dropdown menu.
  3. Select Other…
  4. Click the Select Best Server button. Ubuntu will ping several servers and automatically select the fastest one for your location.
  5. Click Choose Server, enter your password, and click Close. You will be prompted to reload the software lists.

For Ubuntu Server (Terminal)

If you do not have a graphical interface, you can change your mirror by editing your sources.list file.

  1. Backup your current list:
    sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
  2. Use sed to automatically replace your current country code mirror (e.g., us.archive or in.archive) with the main, global Ubuntu server:
    sudo sed -i 's/http:\/\/[a-z]*.archive.ubuntu.com/http:\/\/archive.ubuntu.com/g' /etc/apt/sources.list
  3. Run the update again.

5. Identify Broken Third-Party PPAs

Sometimes, the official Ubuntu servers are fine, but a third-party Personal Package Archive (PPA) that you added manually has gone offline. Because apt-get update checks every repository sequentially, one dead PPA can hang the entire process.

To see exactly which server is causing the hang, run the update command with debugging enabled:

sudo apt-get -o Debug::Acquire::http=true update

Watch the verbose output. If it stops scrolling and hangs immediately after trying to connect to a specific URL (like a random developer’s PPA), you have found the culprit. You can then navigate to /etc/apt/sources.list.d/ and delete or comment out the `.list` file associated with that broken repository.

\n

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.

Receive our best articles and tips delivered straight to your inbox.