# CROSSSLOT: Multi-key command spans two slots

> The command touched several keys that hash to different slots, which Redis Cluster refuses instead of running a partial command.

Source: https://sqlly.app/errors/redis/crossslot
Last updated: 2026-11-30
License: Text and data [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) (credit SQLly, sqlly.app); code and SQL snippets [MIT](https://opensource.org/license/mit). [Details](https://sqlly.app/license).
Note: Quoted error message text belongs to its database vendor.

- Error prefix: `CROSSSLOT`
- Category: Cluster and replication

Error message:

```text
CROSSSLOT Keys in request don't hash to the same slot
```

## What it means

CROSSSLOT is a cluster-only error. A command that names more than one key (MGET, MSET, DEL with several keys, SUNION, Lua scripts) must have all its keys in one hash slot, because a cluster can only run a multi-key command atomically on the node that owns that slot. The keys here hash to different slots, so the node refuses the whole command.

Nothing was executed: DEL, for example, will not delete the keys that do belong to this node. The standard fix is hash tags: name keys so the shared part sits in {braces}, and only the brace content is hashed to a slot.

## Common causes

- A multi-key command named keys that hash to different slots.
- Keys are tagged per entity ({user:1}:..., {user:2}:...) and a batch command groups several entities at once.
- A Lua script or a transaction gathers keys from several slots in one call.

## How to fix it

1. Check the slots the keys map to:

   ```sql
   redis-cli -p 7000 CLUSTER KEYSLOT {user:1000}:profile
   redis-cli -p 7000 CLUSTER KEYSLOT {user:2000}:profile
   # Different slots: the command cannot run as one atomic call
   ```
2. Use hash tags so the keys share a slot:

   ```sql
   MSET {user:1000}:name alice {user:1000}:plan pro
   # Both keys hash on 'user:1000' and land in one slot
   ```
3. When atomicity is not required, split the work into per-key commands:

   ```sql
   DEL {user:1000}:name
   DEL {user:1000}:plan
   ```

## Reproduce it safely

```sql
redis-cli -c -p 7000 MSET a 1 b 2
# (error) CROSSSLOT Keys in request don't hash to the same slot
redis-cli -c -p 7000 MSET {d}a 1 {d}b 2
# OK - both keys hash on 'd'
```

## How SQLly helps

SQLly's editor runs the CLUSTER KEYSLOT lookups next to the failing command in one window, and the full CROSSSLOT reply is printed, so you know the command was refused whole and none of the keys were touched.

## Questions

### Do pipelines get CROSSSLOT too?

No. Each command in a pipeline is routed separately. The error is only for a single command naming several keys.

### Why does the cluster not just forward the command?

Atomicity. A multi-key command has to run as one unit on one node; splitting it across nodes could apply half of it and break the guarantee your data relies on.

## Related errors

- [`MOVED`](https://sqlly.app/errors/redis/moved): The key lives on another cluster node
- [`TRYAGAIN`](https://sqlly.app/errors/redis/tryagain): Slot is rehashing, retry the command

The code and message text are from the [Redis documentation and source code](https://redis.io/docs/latest/).
