{
  "schema_version": 2,
  "id": "develop/reference/errors/common/oom",
  "title": "OOM error",
  "url": "https://redis.io/docs/latest/develop/reference/errors/common/oom/",
  "summary": "Redis has reached its memory limit and can't make room for new data.",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-11-02T15:10:28+01:00",
  "page_type": "content",
  "content_hash": "59a3a27200b0b19796e45eeea7ac1a8bcda5fe7a4dad53f012a91c52e8d1ad16",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Redis returns this error when it has reached its memory limit and can't free memory for the command. The limit is the `maxmemory` setting. Commands that add data fail, but commands that read or delete data still work. OOM stands for out of memory.\n\n[code example]\n\nIn redis-py, this error is `OutOfMemoryError: command not allowed when used memory > 'maxmemory'.`\n\nA Lua function, or a script that starts with a `#!lua` line, gets the same error before it starts, unless it has the `allow-oom` or `no-writes` flag. A script without that line gets the error when it calls a command that adds data, with the script's details added to the end."
    },
    {
      "id": "example",
      "title": "Example",
      "role": "example",
      "text": "[code example]"
    },
    {
      "id": "how-to-fix-it",
      "title": "How to fix it",
      "role": "content",
      "text": "First, check how much memory Redis uses with [`INFO memory`](https://redis.io/docs/latest/commands/info). Compare `used_memory_human` with the limit in `maxmemory_human`, and look at `maxmemory_policy`. The policy decides what Redis does when it reaches the limit. With the default policy, `noeviction`, Redis never removes keys to make room. It returns this error instead.\n\nThen choose a fix:\n\n- **Let Redis remove keys.** If you use Redis as a cache, set an eviction policy such as `allkeys-lru`. Redis then removes the least recently used keys to make room for new ones. See [Eviction policies](https://redis.io/docs/latest/develop/reference/eviction#eviction-policies).\n- **Set expiry times on your keys.** The `volatile-*` policies only remove keys that have an expiry time, also called a time to live (TTL). When no key has one, Redis can't free any memory and returns this error, as with `noeviction`.\n- **Raise the memory limit** with `maxmemory`, if the machine has enough memory. See [Using the `maxmemory` configuration directive](https://redis.io/docs/latest/develop/reference/eviction#maxmem).\n- **Use less memory.** Delete keys you no longer need. See [Memory optimization](https://redis.io/docs/latest/operate/oss_and_stack/management/optimization/memory-optimization) for ways to store the same data in less memory."
    }
  ],
  "examples": [
    {
      "id": "overview-ex0",
      "language": "plaintext",
      "code": "OOM command not allowed when used memory > 'maxmemory'.",
      "section_id": "overview"
    },
    {
      "id": "example-ex0",
      "language": "plaintext",
      "code": "> SET newkey \"value\"\n(error) OOM command not allowed when used memory > 'maxmemory'.\n> GET oldkey\n\"value\"",
      "section_id": "example"
    }
  ]
}
