---
isPrivate: true
title: Downgrade the Agent to a prior major version
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > Agent > Agent FAQ > Downgrade the Agent to a prior major version
---

# Downgrade the Agent to a prior major version

## Downgrade the Agent from v7 to v6{% #downgrade-the-agent-from-v7-to-v6 %}

{% tab title="Linux" %}
First, [uninstall Agent v7 from your system](https://docs.datadoghq.com/agent/guide/how-do-i-uninstall-the-agent/).

Then, if you followed the instructions to [upgrade from v6 to v7](https://docs.datadoghq.com/agent/versions/upgrade_to_agent_v6/), run the following Agent installation command to downgrade your Agent from version 7 to version 6:

```shell
DD_API_KEY="<DATADOG_API_KEY>" bash -c "$(curl -L https://install.datadoghq.com/scripts/install_script_agent6.sh)"
```

The command works on all supported versions of Amazon Linux, CentOS, Debian, Fedora, Red Hat, Ubuntu, and SUSE.
{% /tab %}

{% tab title="Windows" %}

1. [Uninstall Agent v7 from your system](https://docs.datadoghq.com/agent/guide/how-do-i-uninstall-the-agent/).
1. [Download the Datadog Agent installer](https://ddagent-windows-stable.s3.amazonaws.com/datadog-agent-6-latest.amd64.msi).
1. Run the installer (as **Administrator**) by opening `datadog-agent-6-latest.amd64.msi`.
1. Follow the prompts, accept the license agreement, and enter your [Datadog API key](https://app.datadoghq.com/organization-settings/api-keys).
1. When the install finishes, you are given the option to launch the Datadog Agent Manager.

**Note**: Links to all available versions of the Windows Installer are [provided in JSON format](https://ddagent-windows-stable.s3.amazonaws.com/installers_v2.json).
{% /tab %}

{% tab title="MacOS" %}
First, [uninstall Agent v7 from your system](https://docs.datadoghq.com/agent/guide/how-do-i-uninstall-the-agent/).

Then, if you followed the instructions to [upgrade from v6 to v7](https://docs.datadoghq.com/agent/versions/upgrade_to_agent_v6/), run the Agent installation command with the environment variable `DD_AGENT_MAJOR_VERSION=6` to downgrade your Agent from version 7 to version 6:

```shell
DD_AGENT_MAJOR_VERSION=6 DD_API_KEY="<DATADOG_API_KEY>" bash -c "$(curl -L https://install.datadoghq.com/scripts/install_mac_os.sh)"
```

{% /tab %}

## Downgrade the Agent from v6 to v5{% #downgrade-the-agent-from-v6-to-v5 %}

This guide assumes you upgraded to the Agent v6 using the [upgrade guide](https://docs.datadoghq.com/agent/guide/upgrade-to-agent-v6/). If so, choose your OS to see the detailed instructions on how to downgrade your Agent from version 6 to version 5:

{% tab title="Linux" %}
**Debian Flavored Systems**:

1. Set up apt so it can download through https and install `curl` and `gnupg`

   ```shell
   sudo apt-get update
   sudo apt-get install apt-transport-https curl gnupg
   ```

1. Remove Beta Repo and Ensure the stable repo is present:

   ```shell
   sudo rm /etc/apt/sources.list.d/datadog-beta.list
   [ ! -f /etc/apt/sources.list.d/datadog.list ] &&  echo 'deb [signed-by=/usr/share/keyrings/datadog-archive-keyring.gpg] https://apt.datadoghq.com/ stable main' | sudo tee /etc/apt/sources.list.d/datadog.list
   sudo touch /usr/share/keyrings/datadog-archive-keyring.gpg
   
   curl https://keys.datadoghq.com/DATADOG_APT_KEY_CURRENT.public | sudo gpg --no-default-keyring --keyring /usr/share/keyrings/datadog-archive-keyring.gpg --import --batch
   curl https://keys.datadoghq.com/DATADOG_APT_KEY_06462314.public | sudo gpg --no-default-keyring --keyring /usr/share/keyrings/datadog-archive-keyring.gpg --import --batch
   curl https://keys.datadoghq.com/DATADOG_APT_KEY_C0962C7D.public | sudo gpg --no-default-keyring --keyring /usr/share/keyrings/datadog-archive-keyring.gpg --import --batch
   curl https://keys.datadoghq.com/DATADOG_APT_KEY_F14F620E.public | sudo gpg --no-default-keyring --keyring /usr/share/keyrings/datadog-archive-keyring.gpg --import --batch
   curl https://keys.datadoghq.com/DATADOG_APT_KEY_382E94DE.public | sudo gpg --no-default-keyring --keyring /usr/share/keyrings/datadog-archive-keyring.gpg --import --batch
   ```

1. If running Ubuntu 14 or earlier or Debian 8 or earlier, copy the keyring to `/etc/apt/trusted.gpg.d`:

   ```shell
   sudo cp /usr/share/keyrings/datadog-archive-keyring.gpg /etc/apt/trusted.gpg.d
   ```

1. Update apt and downgrade the Agent:

   ```shell
   sudo apt-get update
   sudo apt-get remove datadog-agent
   sudo apt-get install datadog-agent
   ```

1. Back-sync configurations and AutoDiscovery templates (optional)

If you made any changes to your configurations or templates, you might want to sync these back for Agent v5.

**Note**: If you made any changes to your configurations to support Agent v6 only options, these do not work with Agent v5.

1. Back-sync custom checks (optional):

If you made any changes or added any new custom checks while testing Agent 6 you might want to enable them back on Agent 5. **Note**: You only need to copy back checks you changed.

   ```shell
   sudo -u dd-agent -- cp /etc/datadog-agent/checks.d/<CHECK>.py /etc/dd-agent/checks.d/
   ```

1. Restart the Agent:

   ```shell
   sudo systemctl restart datadog-agent # Systemd
   sudo /etc/init.d/datadog-agent restart # Upstart
   ```

1. Clean out `/etc/datadog-agent` (optional):

   ```shell
   sudo -u dd-agent -- rm -rf /etc/datadog-agent/
   ```

**Red Hat Flavored Systems**:

1. Remove the Beta Yum repo from your system:

   ```shell
   rm /etc/yum.repos.d/datadog-beta.repo
   [ ! -f /etc/yum.repos.d/datadog.repo ] && echo -e '[datadog]\nname = Datadog, Inc.\nbaseurl = https://yum.datadoghq.com/rpm/x86_64/   \nenabled=1\ngpgcheck=1\nrepo_gpgcheck=1\npriority=1\ngpgkey=https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public\n       https://keys.datadoghq.com/DATADOG_RPM_KEY_4F09D16B.public\n       https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public\n       https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public\n       https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public' | sudo tee /etc/yum.repos.d/datadog.repo
   ```

**Note**: due to a [bug in dnf](https://bugzilla.redhat.com/show_bug.cgi?id=1792506), use `repo_gpgcheck=0` instead of `repo_gpgcheck=1` on RHEL/CentOS 8.1.

1. Update your local yum cache and downgrade the Agent

   ```shell
   sudo yum clean expire-cache metadata
   sudo yum check-update
   sudo yum remove datadog-agent
   sudo yum install datadog-agent
   ```

1. Back-sync configurations and AutoDiscovery templates (optional)

If you made any changes to your configurations or templates, you might want to sync these back for Agent v5.

**Note**: If you made any changes to your configurations to support Agent v6 only options, these do not work with Agent v5.

1. Back-sync custom checks (optional):

If you made any changes or added any new custom checks while testing Agent 6 you might want to enable them back on Agent 5. **Note**: You only need to copy back checks you changed.

   ```shell
   sudo -u dd-agent -- cp /etc/datadog-agent/checks.d/<CHECK>.py /etc/dd-agent/checks.d/
   ```

1. Restart the Agent:

   ```shell
   sudo systemctl restart datadog-agent # Systemd
   sudo /etc/init.d/datadog-agent restart # Upstart
   ```

1. Clean out `/etc/datadog-agent` (optional):

   ```shell
   sudo -u dd-agent -- rm -rf /etc/datadog-agent/
   ```

{% /tab %}

{% tab title="Windows" %}
Run the agent installer package for the latest 5.x version, instructions can be found [in the Datadog agent integration page](https://app.datadoghq.com/account/settings/agent/latest?platform=windows).
{% /tab %}

{% tab title="MacOS" %}

1. Stop the Agent with the systray app, if it's running.
1. Exit the systray app.
1. Uninstall the Datadog Agent application.
1. Install the Agent 5 DMG package using your preferred installation method.

{% /tab %}
