---
title: "Why does Redis refuse writes with an OOM error? | Proofline"
description: "Redis returns the OOM error when memory used is above maxmemory and the eviction policy cannot free space for the write."
url: https://proofline.sh/learn/redis-oom-command-not-allowed/
---

[Learning center](/learn/)

# Why does Redis refuse writes with an OOM error?

Redis returns the OOM error when memory used is above maxmemory and the eviction policy cannot free space for the write. Read INFO memory, INFO stats and the keyspace line: the policy, evicted\_keys and the count of keys with a TTL tell you whether nothing may be evicted or the dataset outgrew the limit. Reads keep working throughout, so the symptom shows up only on writes.

Broken dependencies The Proofline team November 23, 2026 5 min read

## The symptom and its nearby causes

Writes fail with `OOM command not allowed when used memory > 'maxmemory'.` while reads succeed. The reply comes from the server, so the connection and network are fine. [Redis source, server.c](https://github.com/redis/redis/blob/unstable/src/server.c)

Three causes produce the same reply:

-   The policy forbids eviction. With `noeviction`, Redis evicts nothing and returns an error on commands that would add data. Commands that only read existing data still work. `noeviction` is the default in `redis.conf`. [Eviction policies](https://redis.io/docs/latest/develop/reference/eviction/) · [redis.conf](https://github.com/redis/redis/blob/unstable/redis.conf)
-   The policy allows eviction but finds no candidates. The `volatile-*` policies evict only keys with an expiration, and they behave like `noeviction` when no keys have one. ElastiCache's default parameter group uses `volatile-lru`, so a cache whose keys carry no TTL refuses writes exactly as `noeviction` would. [Eviction policies](https://redis.io/docs/latest/develop/reference/eviction/) · [ElastiCache engine parameters](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/ParameterGroups.Engine.html)
-   Something grew faster than eviction can keep up: a new key family without expiry, a few keys that became very large, or memory outside the dataset such as client buffers.

This guide is one of a set on [runtime dependency failures](/learn/runtime-dependency-failures/).

## Why they look alike

All three end with `used_memory` above `maxmemory`. The difference lies in what Redis was allowed to remove and what filled the space. A cache used as a cache usually wants an `allkeys-*` policy; a store used for data that must not disappear, such as queues or locks, often runs `noeviction` deliberately, and there the error is the intended signal that the store is full.

## Read the memory state

These commands read state only.

```
redis-cli -h REDIS_HOST -p 6379 INFO memory | grep -E '^(used_memory|used_memory_dataset|maxmemory|maxmemory_policy|mem_not_counted_for_evict|mem_clients_normal):'
redis-cli -h REDIS_HOST -p 6379 INFO stats | grep -E '^(evicted_keys|current_eviction_exceeded_time):'
redis-cli -h REDIS_HOST -p 6379 INFO keyspace
```

`used_memory` is the total Redis allocated, and `used_memory_dataset` is the part holding data. `maxmemory` and `maxmemory_policy` echo the configuration. `evicted_keys` counts keys evicted because of the limit, and `current_eviction_exceeded_time` is how long, in milliseconds, `used_memory` has stayed above `maxmemory`. The keyspace line reads `db0:keys=...,expires=...`, where `expires` is the number of keys with a TTL. `mem_not_counted_for_evict` is replica and AOF buffer memory left out of the eviction comparison, and `mem_clients_normal` is memory used by normal clients. [INFO fields](https://redis.io/docs/latest/commands/info/) · [maxmemory and buffers](https://redis.io/docs/latest/develop/reference/eviction/)

To size a suspect key, `MEMORY USAGE` reports the bytes a key and its value take. For nested types it samples elements (`SAMPLES`), so the figure is an estimate. [MEMORY USAGE](https://redis.io/docs/latest/commands/memory-usage/)

```
redis-cli -h REDIS_HOST -p 6379 MEMORY USAGE 'cart:checkout:12345'
```

To find large keys you do not know about, `redis-cli --bigkeys` (by size or element count) or `--memkeys` (by memory) scans the whole keyspace with `SCAN`. It does not block the server the way `KEYS` does, but it issues many commands against an instance already in trouble. The `-i` option adds a sleep between `SCAN` calls to lower the load, at the cost of a much longer run. Run it against a replica if you have one; the docs say these modes work on cluster replicas. [Scan for big keys](https://redis.io/docs/latest/develop/tools/cli/)

```
redis-cli -h REPLICA_HOST -p 6379 --memkeys -i 0.01
```

On ElastiCache, `DatabaseMemoryUsagePercentage` is `used_memory/maxmemory` and `Evictions` comes from `evicted_keys`. Read the policy from the parameter group, since `CONFIG` is restricted there. [ElastiCache metrics](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/CacheMetrics.Redis.html) · [Restricted commands](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/SupportedCommands.html) · [describe-cache-parameters](https://docs.aws.amazon.com/cli/latest/reference/elasticache/describe-cache-parameters.html)

```
aws elasticache describe-cache-parameters \
  --profile PROFILE --region REGION --cache-parameter-group-name PARAMETER_GROUP \
  --query "Parameters[?ParameterName=='maxmemory-policy'].ParameterValue" \
  --output text --no-cli-pager
```

## Decision table

| Policy | `evicted_keys` | Keys with TTL | Points to |
| --- | --- | --- | --- |
| `noeviction` | 0 | any | Store full by design; growth or the limit |
| `volatile-*` | 0 or flat | 0 or few | No eviction candidates |
| `volatile-*` | rising | many | TTL keys evicted, persistent keys fill memory |
| `allkeys-*` | rising fast | any | Growth outpaces eviction, or memory outside the dataset |

If `used_memory_dataset` is much smaller than `used_memory`, look at what is not data: `mem_clients_normal` for large client buffers, or replication buffers. [INFO fields](https://redis.io/docs/latest/commands/info/)

## An illustrative incident with two outcomes

This example is illustrative. The `orders` service caches order summaries in an ElastiCache cluster in account `111122223333`. From 15:40 UTC, writes fail with the OOM error and `checkout` falls back to slow database reads.

In the first outcome, the parameter group shows `volatile-lru`. `INFO keyspace` reads `db0:keys=4210388,expires=51200`, and `evicted_keys` has barely moved for a day. A release at 11:00 added a `summary:v2:*` key family written without a TTL. Those keys cannot be evicted under `volatile-lru`, the TTL keys have already been evicted, and the remaining space filled. The data store is behaving as configured; the release changed what it holds. [Cache keys across versions](/learn/redis-cache-invalidation-across-versions/)

In the second outcome, the policy is `allkeys-lru` and `evicted_keys` is climbing by thousands a second. `--memkeys` on a replica finds one list, `export:pending`, at 3.1 GB, grown by a batch job that pushes faster than it consumes. The other keys are being evicted to make room for one key that eviction picks last because it is touched constantly. The problem is that one key's owner, and a larger node would only delay the error.

## Limits

`MEMORY USAGE` with sampling estimates nested values; a list with uneven element sizes can be off by a wide margin. `--bigkeys` ranks keys within each type by size or element count, which is not the same as memory; use `--memkeys` for bytes. [MEMORY USAGE](https://redis.io/docs/latest/commands/memory-usage/) · [Scan for big keys](https://redis.io/docs/latest/develop/tools/cli/)

On ElastiCache Serverless, `MEMORY USAGE` is unavailable. [Restricted commands](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/SupportedCommands.html)

A rising connection count can also raise client memory, and connection limits produce a different error. [Max clients or timeouts](/learn/redis-max-clients-or-timeouts/) · [Read-only production investigation](/learn/read-only-production-investigation/)

## Questions

### Why do Redis reads work while writes fail with OOM?

The OOM check rejects commands that may add data once memory is above `maxmemory` and nothing can be evicted. Commands that only read existing data still run normally, so a cache can look half healthy.

### Can volatile-lru return an OOM error?

Yes. The `volatile-*` policies evict only keys with an expiration. If few or no keys have a TTL, they behave like `noeviction` and refuse writes once memory is full.

### Is redis-cli --bigkeys expensive?

It scans every key with `SCAN` rather than blocking with `KEYS`, so it does not stall the server, but it sends many commands and takes a long time on large datasets. Throttle it with `-i` and prefer a replica.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Redis max clients reached, or timeouts from a slow server?](/learn/redis-max-clients-or-timeouts/)
    
    Capacity overruns The Proofline team November 23, 2026 6 min read
    
-   ### [Keep old and new cache entries consistent when both releases write](/learn/redis-cache-invalidation-across-versions/)
    
    Deployment failures The Proofline team November 22, 2026 2 min read
