> ## Documentation Index
> Fetch the complete documentation index at: https://help.freakhosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Fix apt Release File and dnf Metadata Errors

> Fix apt update "does not have a Release file", NO_PUBKEY and "not valid yet" errors, and dnf "Failed to download metadata for repo" on Ubuntu and AlmaLinux.

Repository errors mean `apt update` or `dnf` couldn't fetch or trust a package source. The error names the repository: most often it is a third-party repository with the wrong release name or a missing signing key, a server clock that is wrong, or DNS that doesn't work. Read which repository fails, then fix or disable that one source. The table below matches each message to its fix.

```text theme={null}
E: The repository 'http://archive.ubuntu.com/ubuntu jammy-nonexist Release' does not have a Release file.
Error: Failed to download metadata for repo 'appstream': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
```

| Difficulty | Time | Works on | Needs |
| - | - | - | - |
| Intermediate | 5 to 20 minutes | Ubuntu 22.04 / 24.04, Debian 12 / 13, AlmaLinux and Rocky Linux 9 / 10 | Root or sudo access |

## Before you start

* Run `sudo apt update` or `sudo dnf makecache` and copy the **first** error line. Later lines often repeat it.
* Repository files live in `/etc/apt/sources.list.d/` (and `/etc/apt/sources.list`) on Ubuntu and Debian, and in `/etc/yum.repos.d/` on AlmaLinux and Rocky. Ubuntu 24.04 keeps its own sources in `/etc/apt/sources.list.d/ubuntu.sources`.
* Use only supported releases (Ubuntu 22.04/24.04, Debian 12/13, AlmaLinux and Rocky 9/10). Repositories for end-of-life releases are moved or removed, which causes these errors.
* Commands use `sudo`. As root, leave it out.

## Which error do you have?

| Message (shortened) | Cause |
| - | - |
| `does not have a Release file` | Wrong release name, or the repository doesn't support your release (Cause 1) |
| `NO_PUBKEY ...` / `is not signed` | Signing key missing (Cause 2) |
| `Release file ... is not valid yet` | Server clock is wrong (Cause 3) |
| `Temporary failure resolving` / `Could not resolve` / `Curl error (6)` | DNS doesn't work (Cause 4) |
| `Failed to download metadata for repo` | Mirror, network or a broken repository on dnf (Cause 5) |
| `Hash Sum mismatch` / `File has unexpected size` | Mirror was mid-update or a proxy changed the file (Cause 6) |
| `W: Target Packages ... is configured multiple times` | Duplicate source line, only a warning (Cause 6) |

## Cause 1: Wrong release name (does not have a Release file)

**Check** your release code name and the failing line:

```bash theme={null}
. /etc/os-release && echo "$VERSION_CODENAME"
grep -rn 'jammy' /etc/apt/sources.list /etc/apt/sources.list.d/
```

```text theme={null}
noble
/etc/apt/sources.list.d/example.list:1:deb http://repo.example.com/ubuntu jammy main
```

Replace `jammy` with the name the error shows.

**Fix:** set the repository to your code name (`noble` for Ubuntu 24.04, `jammy` for 22.04, `trixie` for Debian 13, `bookworm` for Debian 12), but only if the vendor publishes packages for it. If they don't, disable the file by renaming it, then run `sudo apt update`:

```bash theme={null}
sudo mv /etc/apt/sources.list.d/example.list /etc/apt/sources.list.d/example.list.disabled
```

## Cause 2: Missing signing key (NO\_PUBKEY)

```text theme={null}
W: GPG error: http://repo.example.com noble InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 26AD41C7B70F07B1
E: The repository 'http://repo.example.com noble InRelease' is not signed.
```

APT refuses unsigned or unverifiable repositories by default.

**Fix:** download the key from the vendor's own installation page into `/etc/apt/keyrings`, and reference it with `signed-by`:

```bash theme={null}
sudo install -d -m 0755 /etc/apt/keyrings
curl -fsSL https://repo.example.com/key.asc | sudo tee /etc/apt/keyrings/example.asc > /dev/null
```

```text theme={null}
deb [signed-by=/etc/apt/keyrings/example.asc] http://repo.example.com/ubuntu noble main
```

Armored keys must end in `.asc`, binary keys in `.gpg`. Don't use `apt-key`; it is deprecated.

## Cause 3: The server clock is wrong (not valid yet)

```text theme={null}
E: Release file for http://archive.ubuntu.com/ubuntu/dists/noble/InRelease is not valid yet (invalid for another 2h 13min 5s). Updates for this repository will not be applied.
```

**Check:** `timedatectl` should show `System clock synchronized: yes` and the correct time.

**Fix:** turn on time sync with `sudo timedatectl set-ntp true`. See [set the timezone and time sync](https://help.freakhosting.com/portals/other/how-to-set-the-timezone-and-time-sync-on-linux.md).

## Cause 4: DNS doesn't work

`Temporary failure resolving 'archive.ubuntu.com'` or `Curl error (6): Couldn't resolve host name` means the server can't look up names. Fix DNS first: see [temporary failure in name resolution](https://help.freakhosting.com/portals/other/how-to-fix-temporary-failure-in-name-resolution.md).

## Cause 5: dnf can't download repository metadata

**Check** which repository fails and whether the others work:

```bash theme={null}
sudo dnf repolist
sudo dnf makecache
```

**Fix**, in this order:

```bash theme={null}
sudo dnf clean all
sudo dnf makecache
```

If one repository still fails, skip it for one command to finish urgent work, then fix or disable it:

```bash theme={null}
sudo dnf --disablerepo=example update
sudo dnf config-manager --disable example
```

A common case is an add-on repository (such as EPEL or a vendor repository) installed for another major version, for example `el8` packages on AlmaLinux 9. Remove its release package and install the one for your version, as the vendor documents. `dnf config-manager` comes from the `dnf-plugins-core` package.

## Cause 6: Bad download or duplicate entries

For `Hash Sum mismatch` or `File has unexpected size`, wait a few minutes (the mirror may be updating), then clear the downloaded lists and fetch them again:

```bash theme={null}
sudo rm -rf /var/lib/apt/lists/*
sudo apt update
```

For `configured multiple times`, the warning names two files and line numbers. Delete one of the duplicate lines.

## How to check it worked

```bash theme={null}
sudo apt update
```

It should end without `E:` or `W:` lines. On AlmaLinux and Rocky, `sudo dnf makecache` should end with `Metadata cache created.`

## Frequently asked questions

### Can I ignore a failing third-party repository?

APT still updates the other repositories, but you get no updates from that one, which can include security fixes. Fix or disable it.

### Should I use `[trusted=yes]` to get rid of NO\_PUBKEY?

No. It turns off signature checks, so you would install whatever the repository serves. Add the vendor's key instead.

### My release is end-of-life. How do I fix its repositories?

Upgrade to a supported release instead. See [upgrade Ubuntu to a new release](https://help.freakhosting.com/portals/other/how-to-upgrade-ubuntu-to-a-new-release.md) or [upgrade Debian 12 to Debian 13](https://help.freakhosting.com/portals/other/how-to-upgrade-debian-12-to-debian-13.md).

## Related guides

> [card] [VPS and dedicated server guides](https://help.freakhosting.com/portals/other/vps-and-dedicated-server-guides.md)
>
> Every guide in this section.

> [card] [Update Linux packages](https://help.freakhosting.com/portals/other/how-to-update-linux-packages.md)
>
> apt and dnf updates done right.

> [card] [Could not get lock](https://help.freakhosting.com/portals/other/how-to-fix-could-not-get-lock-var-lib-dpkg-lock.md)
>
> When another install is running.

> [card] [Name resolution failure](https://help.freakhosting.com/portals/other/how-to-fix-temporary-failure-in-name-resolution.md)
>
> Fix DNS on the server.

> [card] [Time sync on Linux](https://help.freakhosting.com/portals/other/how-to-set-the-timezone-and-time-sync-on-linux.md)
>
> Keep the clock correct.

***

> [!NOTE]
>
> **Checked against the official Debian [sources.list](https://manpages.debian.org/trixie/apt/sources.list.5.en.html) and [apt-secure](https://manpages.debian.org/trixie/apt/apt-secure.8.en.html) manuals, the [DNF command reference](https://dnf.readthedocs.io/en/latest/command_ref.html) and [Red Hat's guide to managing repositories](https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/managing_software_with_the_dnf_tool/assembly_managing-custom-software-repositories_managing-software-with-the-dnf-tool)** on 4 November 2026; the "does not have a Release file", NO\_PUBKEY, "not valid yet", DNS and duplicate-entry messages were reproduced with test sources on Ubuntu 24.04 LTS (apt 2.8.3). The dnf commands were not tested.

> [!NOTE]
>
> ### Need Extra Help?
>
> If you encounter any issues, our support team is ready to assist:
>
> * **Live Chat:** Quick assistance via our website.
> * **Support Ticket:** [Open a Ticket](https://freakhosting.com/clientarea/submitticket.php)
> * **Discord:** [Join our Community](https://discord.gg/freakhosting)
> * **Email:** [support@freakhosting.com](mailto:support@freakhosting.com)

> [!TIP]
>
> ### Save on Your Hosting
>
> Ready to upgrade your hosting? Use code **KB20** at checkout for **20% off** your first order!

***

**Last Updated:** November 2026


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.