{
  "schema_version": 2,
  "id": "operate/rs/databases/import-export/flush",
  "title": "Flush database data",
  "url": "https://redis.io/docs/latest/operate/rs/databases/import-export/flush/",
  "summary": "To delete the data in a database without deleting the database, you can use Redis CLI to flush it from the database. Learn how to flush data from standard databases, OSS Cluster API databases, and Active-Active databases using Redis CLI, the Cluster Manager UI, and the Redis Software REST API.",
  "tags": [
    "docs",
    "operate",
    "rs"
  ],
  "last_updated": "2026-10-02T16:06:07+01:00",
  "page_type": "content",
  "content_hash": "f1329fa6cfdecd03a3fb7e2ce319acdb89d2a2a60481e0f2118f575a67019974",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "To delete the data in a database without deleting the database configuration,\nyou can flush the data from the database.\n\nYou can use the Cluster Manager UI to flush data from Active-Active databases.\n\n> [!WARNING] Data Loss Warning\n> The flush command deletes ALL in-memory and persistence data in the database.\n> We recommend that you [back up your database](https://redis.io/docs/latest/operate/rs/databases/import-export/schedule-backups) before you flush the data."
    },
    {
      "id": "flush-data-from-a-database",
      "title": "Flush data from a database",
      "role": "content",
      "text": "From the command line, you can flush a database with the redis-cli command or with your favorite Redis client.\n\nTo flush data from a database with the redis-cli, run:\n\n[code example]\n\nExample:\n\n[code example]\n\n> [!NOTE]\n> Port 9443 is the default [port configuration](https://redis.io/docs/latest/operate/rs/networking/port-configurations#ports-and-port-ranges-used-by-redis-software)."
    },
    {
      "id": "flush-data-from-an-oss-cluster-api-database",
      "title": "Flush data from an OSS Cluster API database",
      "role": "content",
      "text": "When using the OSS Cluster API, the `FLUSHDB` command only flushes the keys of the shard you're connected to, not all keys in the database. To flush all data from an OSS Cluster API database, you need to connect to each endpoint IP address and run the flush command.\n\nFollow these steps to flush all data from an OSS Cluster API database:\n\n1. Find all IP addresses associated with the database endpoint using the `dig` command:\n\n   [code example]\n\n2. Connect to each IP address using [`redis-cli`](https://redis.io/docs/latest/operate/rs/references/cli-utilities/redis-cli) and run the [`FLUSHDB`](https://redis.io/docs/latest/commands/flushdb) command:\n\n   [code example]"
    },
    {
      "id": "example",
      "title": "Example",
      "role": "example",
      "text": "1. Find all IP addresses for the database endpoint:\n\n   [code example]\n\n2. Connect to each IP address and flush the data:\n\n   [code example]\n\nThis ensures that all shards in the OSS Cluster API database are flushed properly."
    },
    {
      "id": "flush-data-from-an-active-active-database",
      "title": "Flush data from an Active-Active database",
      "role": "content",
      "text": "When you flush an Active-Active database (formerly known as CRDB), all of the replicas flush their data at the same time.\n\n> [!NOTE]\n> Run flush from only one participating cluster. The flush operation propagates to all other clusters automatically.\n\nTo flush data from an Active-Active database, use one of the following methods:\n\n- Cluster Manager UI\n\n    1. On the **Databases** screen, select the database from the list, then click **Configuration**.\n\n    1. Click ![Toggle actions button](https://redis.io/docs/latest/images/rs/buttons/button-toggle-actions-vertical.png#no-click) to open a list of additional actions.\n\n    1. Select **Flush database**.\n\n    1. Enter the name of the Active-Active database to confirm that you want to flush the data.\n\n    1. Click **Flush**.\n\n- Command line\n\n    1. To find the ID of the Active-Active database, run:\n\n        [code example]\n\n        For example:\n\n        [code example]\n\n    1. To flush the Active-Active database, run:\n\n        [code example]\n\n        The command output contains the task ID of the flush task, for example:\n\n        [code example]\n\n    1. To check the status of the flush task, run:\n\n        [code example]\n\n        For example:\n\n        [code example]\n\n- REST API\n\n    1. To find the ID of the Active-Active database, use [`GET /v1/crdbs`](https://redis.io/docs/latest/operate/rs/references/rest-api/requests/crdbs#get-all-crdbs):\n\n        [code example]\n\n    1. To flush the Active-Active database, use [`PUT /v1/crdbs/{guid}/flush`](https://redis.io/docs/latest/operate/rs/references/rest-api/requests/crdbs/flush#put-crdbs-flush):\n\n        [code example]\n\n        The command output contains the task ID of the flush task.\n\n    1. To check the status of the flush task, use [`GET /v1/crdb_tasks`](https://redis.io/docs/latest/operate/rs/references/rest-api/requests/crdb_tasks#get-crdb_task):\n\n        [code example]"
    }
  ],
  "examples": [
    {
      "id": "flush-data-from-a-database-ex0",
      "language": "sh",
      "code": "redis-cli -h <hostname> -p <portnumber> -a <password> flushall",
      "section_id": "flush-data-from-a-database"
    },
    {
      "id": "flush-data-from-a-database-ex1",
      "language": "sh",
      "code": "redis-cli -h redis-12345.cluster.local -p 9443 -a xyz flushall",
      "section_id": "flush-data-from-a-database"
    },
    {
      "id": "flush-data-from-an-oss-cluster-api-database-ex0",
      "language": "sh",
      "code": "dig +noall +answer <database-endpoint>",
      "section_id": "flush-data-from-an-oss-cluster-api-database"
    },
    {
      "id": "flush-data-from-an-oss-cluster-api-database-ex1",
      "language": "sh",
      "code": "redis-cli -h <ip-address> -p <port> flushdb",
      "section_id": "flush-data-from-an-oss-cluster-api-database"
    },
    {
      "id": "example-ex0",
      "language": "sh",
      "code": "$ dig +noall +answer redis-19674.test2f4e15b0.cs.redislabs.com\n   redis-19674.test2f4e15b0.cs.redislabs.com. 5 IN A 192.0.2.0\n   redis-19674.test2f4e15b0.cs.redislabs.com. 5 IN A 198.51.100.0",
      "section_id": "example"
    },
    {
      "id": "example-ex1",
      "language": "sh",
      "code": "$ redis-cli -h 192.0.2.0 -p 19674 flushdb\n   OK\n   $ redis-cli -h 198.51.100.0 -p 19674 flushdb\n   OK",
      "section_id": "example"
    },
    {
      "id": "flush-data-from-an-active-active-database-ex0",
      "language": "sh",
      "code": "crdb-cli crdb list",
      "section_id": "flush-data-from-an-active-active-database"
    },
    {
      "id": "flush-data-from-an-active-active-database-ex1",
      "language": "sh",
      "code": "$ crdb-cli crdb list\n        CRDB-GUID                                NAME                 REPL-ID CLUSTER-FQDN\n        a16fe643-4a7b-4380-a5b2-96109d2e8bca     crdb1                1       cluster1.local\n        a16fe643-4a7b-4380-a5b2-96109d2e8bca     crdb1                2       cluster2.local\n        a16fe643-4a7b-4380-a5b2-96109d2e8bca     crdb1                3       cluster3.local",
      "section_id": "flush-data-from-an-active-active-database"
    },
    {
      "id": "flush-data-from-an-active-active-database-ex2",
      "language": "sh",
      "code": "crdb-cli crdb flush --crdb-guid <CRDB-GUID>",
      "section_id": "flush-data-from-an-active-active-database"
    },
    {
      "id": "flush-data-from-an-active-active-database-ex3",
      "language": "sh",
      "code": "$ crdb-cli crdb flush --crdb-guid a16fe643-4a7b-4380-a5b2-96109d2e8bca\n        Task 63239280-d060-4639-9bba-fc6a242c19fc created\n        ---> Status changed: queued -> started",
      "section_id": "flush-data-from-an-active-active-database"
    },
    {
      "id": "flush-data-from-an-active-active-database-ex4",
      "language": "sh",
      "code": "crdb-cli task status --task-id <Task-ID>",
      "section_id": "flush-data-from-an-active-active-database"
    },
    {
      "id": "flush-data-from-an-active-active-database-ex5",
      "language": "sh",
      "code": "$ crdb-cli task status --task-id 63239280-d060-4639-9bba-fc6a242c19fc\n        Task-ID: 63239280-d060-4639-9bba-fc6a242c19fc\n        CRDB-GUID: -\n        Status: finished",
      "section_id": "flush-data-from-an-active-active-database"
    },
    {
      "id": "flush-data-from-an-active-active-database-ex6",
      "language": "sh",
      "code": "GET https://[host][:port]/v1/crdbs",
      "section_id": "flush-data-from-an-active-active-database"
    },
    {
      "id": "flush-data-from-an-active-active-database-ex7",
      "language": "sh",
      "code": "PUT https://[host][:port]/v1/crdbs/<guid>/flush",
      "section_id": "flush-data-from-an-active-active-database"
    },
    {
      "id": "flush-data-from-an-active-active-database-ex8",
      "language": "sh",
      "code": "GET https://[host][:port]/v1/crdb_tasks/<task-id>",
      "section_id": "flush-data-from-an-active-active-database"
    }
  ]
}
