How to fix W: GPG error: URL Release: The following signatures were invalid: BADSIG in APT
This error occurs when APT package manager fails to verify the cryptographic signature of a repository's Release file. The signature verification failure indicates that either the repository's GPG key has changed, your local package lists are corrupted, or there's a network issue during verification.
Quick fix
Fixes BADSIG
sudo apt-get clean
cd /var/lib/apt
sudo mv lists lists.old
sudo mkdir -p lists/partial
sudo apt-get update- Clear the APT package lists cache
- Verify the repository URL is correct
- Re-import the GPG key from a keyserver
- Remove and re-add problematic PPA repositories
sudo apt-get cleancd /var/lib/aptsudo mv lists lists.oldsudo mkdir -p lists/partialsudo apt-get updateW: GPG error: URL Release: The following signatures were invalid: BADSIG
What this error means
The BADSIG (Bad Signature) error means that APT has detected a mismatch between the cryptographic signature of a package repository's Release file and the expected signature from the repository's GPG key. Each repository signs its packages with a private GPG key, and APT verifies these signatures using the corresponding public key stored in your system's keyring. When the signature fails verification, it indicates either a legitimate change in the repository's signing key, corruption in your local package metadata, or a compromise in the delivery of the package data.
Typical symptoms
- apt update or apt-get update fails with BADSIG error message
- Error message displays a hexadecimal key ID (e.g., BADSIG 648ACFD622F3D138)
- Specific repository URL is mentioned in the error output
- Cannot install or update packages until the error is resolved
- Error may appear only for certain repositories (especially third-party PPAs)
Common causes
- Corrupted or outdated package lists in /var/lib/apt/lists directory (most common)
- Repository has updated its GPG signing key but your keyring hasn't been updated
- GPG key for the repository is missing from your system's keyring
- Network issues or proxy interference during package list download
- Third-party repository (PPA) has changed or expired its signing key
- Local apt cache contains corrupted metadata from a failed previous update
How to fix "W: GPG error: URL Release: The following signatures were invalid: BADSIG"
This is the most common and effective fix. The corrupted cached package lists are often the culprit:
sudo apt-get clean
cd /var/lib/apt
sudo mv lists lists.old
sudo mkdir -p lists/partial
sudo apt-get updateThis sequence removes the corrupted package lists and allows apt to re-download fresh, valid ones.
Check your APT sources to ensure the repository URL hasn't been replaced with a malicious or broken mirror:
sudo nano /etc/apt/sources.listAlso check the sources.list.d directory:
ls /etc/apt/sources.list.d/If you see an unfamiliar repository causing the error, comment it out by adding a # at the beginning of its line.
Extract the key ID from the BADSIG error message (the hexadecimal number), then re-import it:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys <KEY_ID>Replace <KEY_ID> with the actual ID from your error message. For example:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 648ACFD622F3D138Then try updating again:
sudo apt-get updateIf the error is from a third-party PPA, disable it temporarily, update, then re-enable it:
# Disable the PPA by renaming its config file
sudo mv /etc/apt/sources.list.d/ppa-name.list /etc/apt/sources.list.d/ppa-name.list.off
# Update to forget the source
sudo apt-get update
# Re-enable the PPA
sudo mv /etc/apt/sources.list.d/ppa-name.list.off /etc/apt/sources.list.d/ppa-name.list
# Update again
sudo apt-get updateOr use ppa-purge to completely remove a PPA:
sudo apt-get install ppa-purge
sudo ppa-purge ppa:user/ppa-nameIf you're behind a corporate proxy or firewall, ensure it's not intercepting repository downloads:
# Test connectivity to a repository
curl -I http://archive.ubuntu.com/ubuntu/ReleaseIf using a proxy, verify your APT proxy configuration:
sudo nano /etc/apt/apt.conf.d/proxy.confAdd or verify your proxy settings:
Acquire::http::Proxy "http://proxy-address:port";If the proxy is the issue, you may need to contact your IT team or bypass it if possible.
Advanced notes
For Ubuntu 18.04 and older: The apt-key command used above is deprecated in newer Ubuntu versions. If you're using Ubuntu 20.04+, consider using the newer method:
wget -O- https://keyserver.ubuntu.com/pks/lookup?op=get&search=<KEY_ID> | sudo gpg --dearmor -o /usr/share/keyrings/repository-name.gpgThen update your sources.list to reference the keyring:
deb [signed-by=/usr/share/keyrings/repository-name.gpg] http://repository.url/ focal mainFor apt-cacher-ng users: If you use apt-cacher-ng (a local apt caching proxy), clear its cache:
sudo /etc/init.d/apt-cacher-ng stop
sudo rm -rf /var/cache/apt-cacher-ng/*
sudo /etc/init.d/apt-cacher-ng start
sudo apt-get updateSystem clock issues: Rarely, if your system clock is significantly out of sync with the repository's certificates, GPG verification can fail. Ensure your system time is correct:
date
sudo timedatectl set-ntp trueFrequently asked questions
- What does "BADSIG" mean?
- The BADSIG (Bad Signature) error means that APT has detected a mismatch between the cryptographic signature of a package repository's Release file and the expected signature from the repository's GPG key. Each repository signs its packages with a private GPG key, and APT verifies these signatures using the corresponding public key stored in your system's keyring. When the signature fails verification, it indicates either a legitimate change in the repository's signing key, corruption in your local package metadata, or a compromise in the delivery of the package data.
- How do I fix "BADSIG"?
- This error occurs when APT package manager fails to verify the cryptographic signature of a repository's Release file. The signature verification failure indicates that either the repository's GPG key has changed, your local package lists are corrupted, or there's a network issue during verification.
- What causes "BADSIG"?
- Corrupted or outdated package lists in /var/lib/apt/lists directory (most common) Repository has updated its GPG signing key but your keyring hasn't been updated GPG key for the repository is missing from your system's keyring
- Is the "BADSIG" error serious?
- It is a medium-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐APT Official Documentation
- ๐
- ๐
- ๐
- ๐