# BUSYKEY error

```json metadata
{
  "schema_version": 2,
  "title": "BUSYKEY error",
  "description": "RESTORE tried to create a key that already exists.",
  "categories": ["docs","develop","stack","oss","rs","rc","oss","kubernetes","clients"],
  "tableOfContents": {"sections":[{"id":"example","title":"Example"},{"id":"how-to-fix-it","title":"How to fix it"}]}

,
  "codeExamples": []
}
```


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.

```
BUSYKEY Target key name already exists.
```

## Example

```
> SET mykey "value"
OK
> RESTORE mykey 0 "<serialized-value>"
(error) BUSYKEY Target key name already exists.
```

## How to fix it

- **To replace the existing key,** add the `REPLACE` option: `RESTORE mykey 0 "<serialized-value>" REPLACE`.
- **To keep the existing key,** restore the value under a different key name.

[`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.

