# redis.exceptions.ResponseError: -OOM command not allowed when used memory > 'maxmemory'.

- **ID:** `database/redis-maxmemory-policy-eviction-blocked`
- **Domain:** database
- **Category:** resource_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

Redis has reached its maxmemory limit and the configured eviction policy (maxmemory-policy) cannot free enough space, or the policy is set to 'noeviction', causing write commands to be rejected.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Redis 6.2 | active | — | — |
| Redis 7.0 | active | — | — |
| Redis 7.2 | active | — | — |

## Workarounds

1. **Set an appropriate eviction policy: CONFIG SET maxmemory-policy allkeys-lru (or volatile-lru, allkeys-lfu, etc.) via redis-cli. Then verify with CONFIG GET maxmemory-policy.** (90% success)
   ```
   Set an appropriate eviction policy: CONFIG SET maxmemory-policy allkeys-lru (or volatile-lru, allkeys-lfu, etc.) via redis-cli. Then verify with CONFIG GET maxmemory-policy.
   ```
2. **Increase maxmemory if feasible: CONFIG SET maxmemory 2gb (or edit redis.conf and restart). Also monitor memory usage with INFO memory to ensure the new limit is sufficient.** (80% success)
   ```
   Increase maxmemory if feasible: CONFIG SET maxmemory 2gb (or edit redis.conf and restart). Also monitor memory usage with INFO memory to ensure the new limit is sufficient.
   ```

## Dead Ends

- **Increase maxmemory without addressing the eviction policy or data growth pattern** — Memory will eventually fill up again if the root cause (e.g., unbounded cache growth, no eviction) is not fixed. (80% fail)
- **Flush all keys using FLUSHALL or FLUSHDB without restarting or changing config** — While this temporarily frees memory, the same pattern of writes will cause the error to recur unless the eviction policy is adjusted. (70% fail)
