# BLPOP

> Remove and return the first element of the first non-empty list, waiting until one is available.

URL: https://docs.hotkv.com/commands/blpop/

```
BLPOP key [key ...] timeout
```

- Group: List
- Complexity: O(N) where N is the number of keys given
- HotKV Cloud: all plans
- On-Premise: no license needed

`BLPOP` is the blocking form of [LPOP](https://docs.hotkv.com/commands/lpop/index.md). It checks the keys in
the order given and pops the first element of the first one that holds a
non-empty list. If every list is empty or missing, the connection waits until
another client pushes to one of the keys, or until `timeout` passes.

While waiting, the client is served from whichever of its keys receives an
element first. A key that changes to a different type while you wait is
skipped, and the client keeps waiting.

`timeout` is in seconds and can have a fractional part (for example `0.5`).
`0` waits forever.

Inside [MULTI](https://docs.hotkv.com/commands/multi/index.md) / [EXEC](https://docs.hotkv.com/commands/exec/index.md) and inside scripts,
`BLPOP` never waits: if no element is available it replies right away as if
the timeout had expired.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Element popped | Two-element array: the key, then the element | Same |
| Timeout expired | Nil array | Null |

Errors:

- `ERR timeout is not a float or out of range` if `timeout` is not a number.
- `ERR timeout is negative` if `timeout` is below 0.
- `ERR timeout is out of range` if `timeout` is too large.
- `WRONGTYPE` if a key reached before the first non-empty list holds a value
  that is not a list.

## Examples

```
127.0.0.1:6379> RPUSH jobs j1 j2
(integer) 2
127.0.0.1:6379> BLPOP empty jobs 5
1) "jobs"
2) "j1"
127.0.0.1:6379> BLPOP empty 1.5
(nil)
(1.50s)
```

Waiting for work in one client:

```
127.0.0.1:6379> BLPOP jobs:new 0
```

and pushing from another:

```
127.0.0.1:6379> RPUSH jobs:new "build-42"
(integer) 1
```

The first client then receives:

```
1) "jobs:new"
2) "build-42"
```

## Compatibility

Same as Redis 7.4 and Valkey 8.

## See also

[BRPOP](https://docs.hotkv.com/commands/brpop/index.md), [LPOP](https://docs.hotkv.com/commands/lpop/index.md), [BLMPOP](https://docs.hotkv.com/commands/blmpop/index.md),
[BLMOVE](https://docs.hotkv.com/commands/blmove/index.md), [RPUSH](https://docs.hotkv.com/commands/rpush/index.md)