Fix apt update E: Repository no longer has a Release file

Advanced 25 min Apr 17, 2026 20 views
Ubuntu 24.04 Ubuntu 22.04 Debian 12 Debian 11 AlmaLinux 9 Rocky Linux 9 Fedora 41

Resolve apt update errors when repositories lose Release files due to expired GPG keys, discontinued repos, or corrupted package manager state. Includes diagnostics, recovery methods, and prevention strategies.

Prerequisites

  • Root or sudo access
  • Basic command line knowledge
  • Understanding of Linux package management

What this solves

The "E: Repository no longer has a Release file" error appears when apt update cannot verify a repository's authenticity or structure. This happens when repositories change their signing keys, discontinue services, or when your package manager cache becomes corrupted. This tutorial shows you how to diagnose the root cause, fix broken configurations, and prevent future repository issues.

Understanding repository structure and Release files

APT repositories use Release files to provide metadata about available packages and cryptographic signatures for verification. Each repository has a Release file containing package indexes, checksums, and expiration dates. When this file is missing, expired, or has invalid signatures, apt refuses to update to prevent potential security issues.

Repository URLs follow a specific structure: deb [options] URL distribution component. The Release file lives at URL/dists/distribution/Release and must be signed by a trusted GPG key in your /etc/apt/trusted.gpg.d/ directory.

Diagnosing the root cause

Check detailed apt update output

Run apt update with verbose output to see exactly which repositories are failing and why.

sudo apt update -v

Examine repository sources

List all configured repositories to identify problematic sources.

grep -r "^deb" /etc/apt/sources.list /etc/apt/sources.list.d/

Test repository accessibility

Manually check if the Release file exists for failing repositories.

curl -I http://example-repo.com/dists/focal/Release
curl -I https://example-repo.com/dists/focal/Release

Check GPG key validity

Verify that repository signing keys are present and not expired.

apt-key list
gpg --list-keys --with-colons /etc/apt/trusted.gpg.d/*.gpg

Fixing corrupted or outdated repository configurations

Remove problematic repository entries

Comment out or remove failing repository entries from your sources.

sudo nano /etc/apt/sources.list

Add # at the beginning of problematic lines:

# deb http://old-repo.example.com/ubuntu focal main
deb http://archive.ubuntu.com/ubuntu focal main restricted

Remove repository-specific source files

Delete individual source files for discontinued repositories.

sudo rm /etc/apt/sources.list.d/problematic-repo.list
ls /etc/apt/sources.list.d/

Update repository URLs

Replace old repository URLs with current mirrors or official sources.

sudo sed -i 's|http://old-repo.example.com|http://archive.ubuntu.com|g' /etc/apt/sources.list

Add missing GPG keys

Import GPG keys for repositories that have updated their signing keys.

curl -fsSL https://example-repo.com/gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/example-repo.gpg
sudo apt update
sudo rpm --import https://example-repo.com/gpg
sudo dnf clean all && sudo dnf update

Recovering from broken package manager state

Clear apt cache and lists

Remove cached repository data that might be corrupted.

sudo rm -rf /var/lib/apt/lists/*
sudo apt clean
sudo apt autoclean

Reset apt preferences

Remove pinning preferences that might interfere with repository access.

sudo rm -f /etc/apt/preferences
sudo rm -f /etc/apt/preferences.d/*

Regenerate repository cache

Force apt to rebuild its repository cache from scratch.

sudo apt update --fix-missing
sudo apt update

Fix broken package dependencies

Repair any package dependency issues caused by repository problems.

sudo apt --fix-broken install
sudo dpkg --configure -a

Advanced recovery techniques

Bypass signature verification temporarily

Only for emergency recovery when you trust the repository source.

Security Risk: This bypasses cryptographic verification. Only use for trusted repositories during recovery.
sudo apt -o Acquire::AllowInsecureRepositories=true -o Acquire::AllowDowngradeToInsecureRepositories=true update

Reset to minimal repository configuration

Create a clean sources.list with only essential repositories.

sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup

For Ubuntu systems:

deb http://archive.ubuntu.com/ubuntu jammy main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu jammy-updates main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu jammy-security main restricted universe multiverse

For Debian systems:

deb http://deb.debian.org/debian bookworm main contrib non-free
deb http://deb.debian.org/debian bookworm-updates main contrib non-free
deb http://security.debian.org/debian-security bookworm-security main contrib non-free

Rebuild trusted keyring

Recreate the GPG keyring if it becomes corrupted.

sudo rm /etc/apt/trusted.gpg
sudo rm /etc/apt/trusted.gpg.d/*
sudo apt-key update
sudo apt update

Preventing future repository issues

Enable automatic key updates

Configure apt to automatically refresh repository keys before they expire.

APT::Key::gpgvcommand "/usr/bin/gpgv --keyring /etc/apt/trusted.gpg";
APT::Update::Pre-Invoke {"gpg --refresh-keys > /dev/null 2>&1 || true";};

Set up repository monitoring

Create a script to check repository health regularly.

#!/bin/bash
set -e

echo "Checking repository accessibility..."
while IFS= read -r line; do
    if [[ $line =~ ^deb[[:space:]]+([^[:space:]]+)[[:space:]]+([^[:space:]]+) ]]; then
        url="${BASH_REMATCH[1]}"
        dist="${BASH_REMATCH[2]}"
        release_url="$url/dists/$dist/Release"
        
        if curl -f -s --max-time 10 "$release_url" > /dev/null; then
            echo "✓ $url ($dist) - OK"
        else
            echo "✗ $url ($dist) - FAILED"
        fi
    fi
done < <(grep -h "^deb " /etc/apt/sources.list /etc/apt/sources.list.d/* 2>/dev/null)

echo "Repository check complete."
sudo chmod +x /usr/local/bin/check-repos.sh
/usr/local/bin/check-repos.sh

Configure repository pinning

Set priorities for repositories to prevent conflicts between similar packages.

Package: *
Pin: origin archive.ubuntu.com
Pin-Priority: 500

Package: *
Pin: origin security.ubuntu.com
Pin-Priority: 500

Package: *
Pin: origin ppa.launchpad.net
Pin-Priority: 100

Set up automated repository backup

Create backups of working repository configurations before making changes.

#!/bin/bash
BACKUP_DIR="/var/backups/apt-config"
TIMESTAMP=$(date +%Y%m%d-%H%M%S)

sudo mkdir -p "$BACKUP_DIR"
sudo tar -czf "$BACKUP_DIR/apt-config-$TIMESTAMP.tar.gz" \
    /etc/apt/sources.list \
    /etc/apt/sources.list.d/ \
    /etc/apt/trusted.gpg.d/ \
    /etc/apt/preferences.d/ \
    2>/dev/null

echo "APT configuration backed up to $BACKUP_DIR/apt-config-$TIMESTAMP.tar.gz"
sudo chmod +x /usr/local/bin/backup-apt-config.sh
/usr/local/bin/backup-apt-config.sh

Working with PPAs and third-party repositories

Safely add third-party repositories

Use the recommended method for adding PPAs and external repositories.

sudo apt install software-properties-common
sudo add-apt-repository ppa:example/ppa
sudo apt update

Remove problematic PPAs

Clean removal of PPAs that are causing issues.

sudo add-apt-repository --remove ppa:problematic/ppa
sudo apt update

Downgrade packages from removed repositories

Revert packages to versions available in official repositories.

sudo apt list --installed | grep -E '(ppa|local)'
sudo apt install package-name/jammy
apt-cache policy package-name

Verify your setup

Test that your repository configuration is working correctly.

sudo apt update
sudo apt list --upgradable
apt-cache policy
/usr/local/bin/check-repos.sh

Common issues

SymptomCauseFix
"Release file expired"Repository hasn't been updatedRemove or replace with current mirror
"GPG signature invalid"Repository changed signing keysImport new GPG key from repository
"Connection timeout"Repository server offlineSwitch to alternative mirror
"Hash mismatch"Corrupted cache or partial downloadClear cache: sudo rm -rf /var/lib/apt/lists/*
PPA gives 404 errorPPA doesn't support your Ubuntu versionRemove PPA or use compatible version
"NO_PUBKEY" errorMissing GPG keysudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys KEYID
Conflicting repositoriesMultiple sources for same packagesSet repository priorities with apt preferences

Next steps

Running this in production?

Repository management at scale gets complex. Keeping package sources healthy across multiple servers, handling mirror outages, and managing custom repositories requires ongoing attention. See how we run infrastructure like this for European teams who need reliable package management.

Need help?

Don't want to manage this yourself?

We handle managed cloud infrastructure for businesses that depend on uptime. From initial setup to ongoing operations.