Memecahkan Masalah Kegagalan Perintah `apt dist-upgrade` dari Repositori Elasticsearch

Problem

The system could run:

sudo apt update

but failed during:

sudo apt dist-upgrade

with:

403 Forbidden
https://artifacts.elastic.co/packages/9.x/apt/.../elasticsearch-9.4.2-amd64.deb

That means package lists were updated successfully, but APT could not download a specific Elasticsearch package archive.


Why this happened

This was not an Ubuntu mirror issue.

Key evidence:

  • apt update succeeded.
  • The failure came only from artifacts.elastic.co.
  • The failing request used IPv6: 2600:1901:0:1d7::.
  • A direct request to the same package URL succeeded over IPv4.

So the root cause was a network/IPv6 path problem to the Elasticsearch repo, not a bad package or repository configuration.


Solution found

Temporary fix

Force APT to use IPv4 for the current operation:

sudo apt -o Acquire::ForceIPv4=true update
sudo apt -o Acquire::ForceIPv4=true dist-upgrade

This bypassed the broken IPv6 route and allowed the package download to succeed.

Permanent fix

Persist the IPv4-only setting for APT:

echo 'Acquire::ForceIPv4 "true";' | sudo tee /etc/apt/apt.conf.d/99force-ipv4

Then run normal updates again:

sudo apt update
sudo apt dist-upgrade

What this means

  • The system itself is healthy enough to update package metadata.
  • The error was isolated to Elasticsearch package retrieval over IPv6.
  • Using IPv4 is a practical workaround when a repo is reachable over IPv4 but not over IPv6.

Optional follow-up

For a cleaner long-term solution, investigate IPv6 connectivity on the host or network. But for now, the immediate problem is solved by forcing APT to use IPv4.

Apakah halaman ini bermanfaat?

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *