How to fix E: Packages were downgraded and -y was used without --allow-downgrades in APT

APTINTERMEDIATEMEDIUMUpdated Dec 29, 2025ยท 234 views

This error occurs when apt attempts to downgrade packages using the -y flag without explicitly allowing downgrades. The --allow-downgrades flag is required when using automated yes (-y) with package downgrades.

Quick fix

Fixes E: Packages were downgraded and -y was used without --allow-downgrades

sudo apt install -y --allow-downgrades package-name=version
  1. Add --allow-downgrades flag to your apt command
  2. For Ansible playbooks, use the allow_downgrade option
  3. Update your cron or CI/CD scripts to include the flag
  4. Verify your package versions before downgrading
apt โ€” error
sudo apt install -y --allow-downgrades package-name=version
E: Packages were downgraded and -y was used without --allow-downgrades

What this error means

APT (Advanced Package Tool) detected that a package downgrade would occur, but you used the -y (automatic yes) flag without including --allow-downgrades. Since package downgrades can potentially break system stability, apt requires explicit permission via the --allow-downgrades flag when combined with automated approval. This safety mechanism prevents accidental downgrades in automated scripts or configurations.

Typical symptoms

  • apt install or apt upgrade fails with "E: Packages were downgraded and -y was used without --allow-downgrades"
  • Ansible apt module fails when trying to install specific older package versions
  • Automated upgrade scripts in cron or CI/CD pipelines fail during package installation
  • Docker or other package updates trigger downgrade errors unexpectedly

Common causes

  1. Using apt with -y flag while attempting to install a version older than what is currently installed
  2. Ansible apt module with allow_downgrade option but missing the flag in the actual apt command
  3. Automated upgrade scripts that do not account for dependency changes causing package versions to downgrade
  4. Package repository changes where a newer version is no longer available, falling back to an older version
  5. Docker or third-party package managers upgrading packages outside the normal apt flow, then apt trying to downgrade them back

How to fix "E: Packages were downgraded and -y was used without --allow-downgrades"

1Add --allow-downgrades flag to your apt command

When using apt with -y to install a specific older version of a package, include the --allow-downgrades flag:

bash
sudo apt install -y --allow-downgrades package-name=version

Example:

bash
sudo apt install -y --allow-downgrades docker-ce=5.20.10~3-0~ubuntu-focal
2For Ansible playbooks, use the allow_downgrade option

If you are using Ansible, ensure your apt module includes the allow_downgrade parameter:

yaml
- name: Install specific package version
  ansible.builtin.apt:
    name: "{{ package_name }}={{ package_version }}"
    state: present
    allow_downgrade: yes

Note: Even with allow_downgrade set, you may need to ensure the generated apt command includes --allow-downgrades for Ansible versions that have this limitation.

3Update your cron or CI/CD scripts to include the flag

If running automated upgrades via cron or CI/CD pipelines, modify your upgrade command:

Old (failing):

bash
apt update && apt upgrade -y

New (if downgrades are needed):

bash
apt update && apt upgrade -y --allow-downgrades

Better alternative - use unattended-upgrades:

bash
sudo apt install unattended-upgrades
sudo dpkg-reconfigure unattended-upgrades

The unattended-upgrades package handles version conflicts intelligently without manual flag management.

4Verify your package versions before downgrading

Before applying the --allow-downgrades flag, understand why the downgrade is happening:

bash
# Check currently installed version
apt list --installed | grep package-name

# Check available versions in repositories
apt policy package-name

# Check what apt would do with a dry run
apt install -y --allow-downgrades --simulate package-name=version

Only proceed with the actual installation if the simulation looks correct.

Advanced notes

The --allow-downgrades flag was introduced in APT 1.1 as a replacement for the deprecated --force-yes option, which was considered too permissive. The --allow-downgrades flag is intentionally strict because downgrading packages can introduce dependency conflicts and break system stability. In production environments, prefer using unattended-upgrades over manual apt commands, as it intelligently handles version conflicts. If you frequently need to downgrade packages, consider investigating why (e.g., Docker version incompatibilities, conflicting package sources) and address the root cause rather than treating downgrades as a routine operation. On systems with multiple package sources, pin specific packages using /etc/apt/preferences to prevent unexpected downgrades.

Frequently asked questions

What does "E: Packages were downgraded and -y was used without --allow-downgrades" mean?
APT (Advanced Package Tool) detected that a package downgrade would occur, but you used the -y (automatic yes) flag without including --allow-downgrades. Since package downgrades can potentially break system stability, apt requires explicit permission via the --allow-downgrades flag when combined with automated approval. This safety mechanism prevents accidental downgrades in automated scripts or configurations.
How do I fix "E: Packages were downgraded and -y was used without --allow-downgrades"?
This error occurs when apt attempts to downgrade packages using the -y flag without explicitly allowing downgrades. The --allow-downgrades flag is required when using automated yes (-y) with package downgrades.
What causes "E: Packages were downgraded and -y was used without --allow-downgrades"?
Using apt with -y flag while attempting to install a version older than what is currently installed Ansible apt module with allow_downgrade option but missing the flag in the actual apt command Automated upgrade scripts that do not account for dependency changes causing package versions to downgrade
Is the "E: Packages were downgraded and -y was used without --allow-downgrades" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading