Executing sudo apt update on Ubuntu systems can suddenly terminate with the cryptographic repository warning: W: GPG error: http://archive.ubuntu.com/ubuntu [release] InRelease: The following signatures were invalid: BADSIG [KEY_ID] [Repository Name], concluding with the fatal notice that The repository is not signed. This error prevents the Advanced Package Tool (APT) from downloading updated package indexes or installing software updates. Unlike missing key errors (NO_PUBKEY), a BADSIG notification indicates that APT successfully downloaded a repository Release file, but its cryptographic signature does not match the file’s binary contents – a sign of network proxy corruption, a desynchronised repository mirror, or damaged local cache files.
Repairing BADSIG errors requires purging corrupted local package lists, refreshing repository mirror definitions, and rebuilding APT trusted cryptographic keys.
Why Does APT Return a BADSIG Error?
APT verifies every repository package index against a detached GPG signature file. The BADSIG error occurs when checksum validation fails due to several specific causes:
- Corrupted Local Package Lists in /var/lib/apt/lists/: Interrupted network downloads leave incomplete or truncated
InReleasefiles on your hard drive, causing cryptographic hash verification to fail. - Repository Mirror Desynchronisation: Upstream Ubuntu archive mirrors (such as regional mirrors like
us.archive.ubuntu.comoruk.archive.ubuntu.com) are actively synchronising from primary canonical servers while you runapt update. The mirror’s Release file has updated, but its corresponding Packages index is still transferring. - Intermediate Proxy or ISP Cache Corruption: Transparent network caching proxies, corporate firewalls, or ISP web accelerators serve a stale cached version of the Release file alongside a newly updated signature.
- Local Disk Sector Inconsistencies: File system errors corrupted the cryptographic key files inside
/etc/apt/trusted.gpg.d/.
Method 1: Purge and Rebuild Local APT Package Lists (Primary Fix)
The vast majority of BADSIG errors are caused by corrupt local index files. Purging the /var/lib/apt/lists/ directory forces APT to pull complete, pristine copies directly from the servers:
- Open your terminal.
- Delete all cached package lists and partial download files:
sudo rm -rf /var/lib/apt/lists/* sudo rm -rf /var/lib/apt/lists/partial/* - Clean the APT archive download cache:
sudo apt clean - Re-run the package manager update:
sudo apt update - APT will rebuild the entire directory structure from scratch, validating fresh cryptographic signatures without BADSIG failures.
Method 2: Switch to the Main Canonical Archive Mirror
If regional or third-party mirrors are desynchronised, redirect APT to canonical primary archive servers:
- Open your sources list in nano:
sudo nano /etc/apt/sources.list - Locate any lines pointing to country-specific mirrors (for example,
http://us.archive.ubuntu.com/ubuntu/orhttp://in.archive.ubuntu.com/ubuntu/). - Replace the country prefix with the global primary mirror address:
http://archive.ubuntu.com/ubuntu/ - Save changes (Ctrl + O, Enter) and exit (Ctrl + X).
- For Ubuntu 24.04 LTS systems using the modern deb822 format, perform this edit in
/etc/apt/sources.list.d/ubuntu.sourcesinstead. - Purge lists and update:
sudo rm -rf /var/lib/apt/lists/* && sudo apt update
Method 3: Refresh the Problematic PPA or Repository Key
If the BADSIG error targets a specific third-party PPA or software vendor repository:
- Note the 8-character or 16-character key hex string displayed in the error message (e.g.,
BADSIG 3B4FE6ACC0B21F32). - Re-fetch the authentic signing key directly from the Ubuntu keyserver:
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com [KEY_ID] - Alternatively, if using modern Ubuntu keyrings under
/etc/apt/keyrings/:sudo gpg --no-default-keyring --keyring /etc/apt/keyrings/problematic-repo.gpg --keyserver keyserver.ubuntu.com --recv-keys [KEY_ID] - Update your local package lists:
sudo apt update
Method 4: Bypass Broken HTTP Caches with Direct Configuration Flags
If your local ISP or corporate gateway is forcing stale HTTP caches:
sudo apt update -o Acquire::http::No-Cache=True -o Acquire::BrokenProxy=true
These flags instruct APT to transmit Cache-Control: no-cache headers across the network, forcing intermediate proxies to pull fresh, uncached copies of the signature files.