{
  "schema_version": 2,
  "id": "develop/reference/errors/common/busykey",
  "title": "BUSYKEY error",
  "url": "https://redis.io/docs/latest/develop/reference/errors/common/busykey/",
  "summary": "RESTORE tried to create a key that already exists.",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-11-02T15:10:28+01:00",
  "page_type": "content",
  "content_hash": "bafa993e8830c20176d5387eefa649e0905f0ad942622d945a6d67df8f054ccd",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Redis returns this error when [`RESTORE`](https://redis.io/docs/latest/commands/restore) would create a key that already exists. `RESTORE` creates a key from a value that [`DUMP`](https://redis.io/docs/latest/commands/dump) serialized. By default, it doesn't overwrite an existing key.\n\n[code example]"
    },
    {
      "id": "example",
      "title": "Example",
      "role": "example",
      "text": "[code example]"
    },
    {
      "id": "how-to-fix-it",
      "title": "How to fix it",
      "role": "content",
      "text": "- **To replace the existing key,** add the `REPLACE` option: `RESTORE mykey 0 \"<serialized-value>\" REPLACE`.\n- **To keep the existing key,** restore the value under a different key name.\n\n[`MIGRATE`](https://redis.io/docs/latest/commands/migrate), which moves keys to another Redis server, also has a `REPLACE` option for keys that already exist on the target server."
    }
  ],
  "examples": [
    {
      "id": "overview-ex0",
      "language": "plaintext",
      "code": "BUSYKEY Target key name already exists.",
      "section_id": "overview"
    },
    {
      "id": "example-ex0",
      "language": "plaintext",
      "code": "> SET mykey \"value\"\nOK\n> RESTORE mykey 0 \"<serialized-value>\"\n(error) BUSYKEY Target key name already exists.",
      "section_id": "example"
    }
  ]
}
