Fixing Redis OOM Error: Command Not Allowed When Used Memory in WordPress

redis oom errorwordpress redis object cacheredis maxmemory configurationoneinstack rediscommand not allowed when used memory
Published·Modified·

Recently, I noticed that certain settings in the WordPress backend were not taking effect, such as pinning posts or updating theme information. Using F12 to inspect the network traffic showed that POST requests returned normal results. I wondered if a plugin was causing the update failure.

Problem Background

  • Environment: Redis service installed via Oneinstack
  • Application: WordPress
  • Plugin: Redis Object Cache

Symptoms: When attempting to pin a post in the WordPress backend, the change did not take effect. Upon checking, the post still showed as unpinned.

Troubleshooting

Based on experience, the first suspect was the Redis Object Cache plugin. Indeed, the plugin status displayed "Not connected."

The Redis process was running on the server, and the port was listening correctly. Additionally, connecting to the Redis service via redis-cli worked normally. So, why could the server connect to Redis successfully, but the Redis Object Cache plugin showed "Not connected"?

Continuing to check the Redis Object Cache plugin logs, I found the error "OOM command not allowed when used memory," as shown below.

The error message was clear: it appeared that Redis memory was either restricted or insufficient. I used the Redis command CONFIG GET maxmemory to check the memory limit, which was set to 473000000 bytes (approximately 400+ MB).

I suspected that the memory limit was too small. Therefore, I modified the redis.conf configuration file:

maxmemory 473000000

Changed to:

maxmemory 1073741824

After restarting the Redis service and the Redis Object Cache plugin in WordPress, the plugin status showed a normal connection, and the error disappeared.

Testing again, the WordPress post pinning function worked normally.

Conclusion

If you use Oneinstack to install Redis, please be aware that you should check the memory size limit in the Redis configuration. Adjust the Redis memory limit according to your server specifications and business requirements to prevent such issues.