Redis Connection Errors — Server Connection Refused and Memory Limit Issues
About Redis Connection Errors
Fix Redis connection errors including ECONNREFUSED, OOM command not allowed, max clients reached, and authentication failures on Linux. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.
Here are the key things to understand: Redis defaults to local-only connections on port 6379 with no authentication. OOM (Out of Memory) errors occur when Redis reaches maxmemory limit. Redis can be configured for persistence (RDB snapshots, AOF log) or as a pure cache. Connection limits (maxclients, default 10000) can be exhausted by applications not closing connections. Redis Sentinel and Cluster add complexity to connection handling. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.
The most common reasons this occurs include: Redis server not running or listening on a different port/address than expected. maxmemory limit reached with no eviction policy — Redis rejects write commands. All client connections used up (maxclients reached). Authentication required but client not providing the password (requirepass set). Identifying the root cause is the first step toward finding the right solution.
To resolve this, follow these recommended steps: Check Redis status: 'systemctl status redis' and 'redis-cli ping' (should return PONG). For OOM: set eviction policy in redis.conf: 'maxmemory-policy allkeys-lru' to evict least-recently-used keys. Check connections: 'redis-cli info clients' shows connected clients and blocked clients. Configure authentication: set 'requirepass yourpassword' in redis.conf, connect with 'redis-cli -a yourpassword'. Monitor in real-time: 'redis-cli monitor' shows all commands being processed (warning: high overhead in production). If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.
This article is part of our Linux Error Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.
Quick Answer
What does OOM command not allowed mean?
Redis has reached its maxmemory limit and no eviction policy is set (or all keys have expiry and none can be evicted). Set maxmemory-policy to allkeys-lru to automatically evict old keys when memory is full.
Overview
Fix Redis connection errors including ECONNREFUSED, OOM command not allowed, max clients reached, and authentication failures on Linux.
Key Details
- Redis defaults to local-only connections on port 6379 with no authentication
- OOM (Out of Memory) errors occur when Redis reaches maxmemory limit
- Redis can be configured for persistence (RDB snapshots, AOF log) or as a pure cache
- Connection limits (maxclients, default 10000) can be exhausted by applications not closing connections
- Redis Sentinel and Cluster add complexity to connection handling
Common Causes
- Redis server not running or listening on a different port/address than expected
- maxmemory limit reached with no eviction policy — Redis rejects write commands
- All client connections used up (maxclients reached)
- Authentication required but client not providing the password (requirepass set)
Steps
- 1Check Redis status: 'systemctl status redis' and 'redis-cli ping' (should return PONG)
- 2For OOM: set eviction policy in redis.conf: 'maxmemory-policy allkeys-lru' to evict least-recently-used keys
- 3Check connections: 'redis-cli info clients' shows connected clients and blocked clients
- 4Configure authentication: set 'requirepass yourpassword' in redis.conf, connect with 'redis-cli -a yourpassword'
- 5Monitor in real-time: 'redis-cli monitor' shows all commands being processed (warning: high overhead in production)