Redis Maximum Client Connections
Let’s talk about the maximum number of client connections in Redis. Redis has a maxclients configuration that sets the maximum number of client connections the Redis server can accept simultaneously (including regular clients, Pub/Sub subscribers, Sentinel, and master-replica replication connections). The default value is 10000.
The maxclients Setting
################################### CLIENTS ####################################
# Set the max number of connected clients at the same time. By default
# this limit is set to 10000 clients, however if the Redis server is not
# able to configure the process file limit to allow for the specified limit
# the max number of allowed clients is set to the current file limit
# minus 32 (as Redis reserves a few file descriptors for internal uses).
#
# Once the limit is reached Redis will close all the new connections sending
# an error 'max number of clients reached'.
#
# IMPORTANT: When Redis Cluster is used, the max number of connections is also
# shared with the cluster bus: every node in the cluster will use two
# connections, one incoming and another outgoing. It is important to size the
# limit accordingly in case of very large clusters.
#
# maxclients 10000
maxclients sets the maximum number of simultaneously connected clients. By default this limit is 10000 clients. However, if the Redis server cannot configure the process’s file-descriptor limit high enough to allow the specified number of clients, the actual allowed maximum is set to the current file-descriptor limit minus 32 (because Redis reserves a few file descriptors for internal use). Once the limit is reached, Redis rejects all new connections and returns the error: max number of clients reached.
Important: When Redis Cluster is used, the maximum number of connections is also shared with the cluster bus: every node in the cluster uses two connections, one incoming and one outgoing. It is therefore important to size this limit accordingly when dealing with very large clusters.
Let’s set maxclients 64000 in redis.conf and look at the actual Redis startup log:
postgres@slpc:~/redis6.0$ ./bin/redis-server redis-node1.conf
31011:C 09 Jan 2026 11:15:35.625 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
31011:C 09 Jan 2026 11:15:35.625 # Redis version=6.0.20, bits=64, commit=de0d9632, modified=0, pid=31011, just started
31011:C 09 Jan 2026 11:15:35.625 # Configuration loaded
31011:M 09 Jan 2026 11:15:35.631 * Increased maximum number of open files to 64032 (it was originally set to 1024). # Redis raised the file-descriptor limit to 64032 on startup
Let’s inspect the file-descriptor limit it set; Max open files is now 64032.
postgres@slpc:~/redis6.0$ ps -ef | grep redis
postgres 31011 28442 0 11:15 pts/1 00:00:02 ./bin/redis-server 0.0.0.0:6379
postgres 34536 34468 0 11:28 pts/3 00:00:00 grep --color=auto redis
postgres@slpc:~/redis6.0$ cat /proc/31011/limits
Limit Soft Limit Hard Limit Units
Max cpu time unlimited unlimited seconds
Max file size unlimited unlimited bytes
Max data size unlimited unlimited bytes
Max stack size 8388608 unlimited bytes
Max core file size unlimited unlimited bytes
Max resident set unlimited unlimited bytes
Max processes 63461 63461 processes
Max open files 64032 64032 files
Max locked memory 2090074112 2090074112 bytes
Max address space unlimited unlimited bytes
Max file locks unlimited unlimited locks
Max pending signals 63461 63461 signals
Max msgqueue size 819200 819200 bytes
Max nice priority 0 0
Max realtime priority 0 0
Max realtime timeout unlimited unlimited us
Check the current connection count:
127.0.0.1:6379> info clients
# Clients
connected_clients:1 # current connection count is 1
client_recent_max_input_buffer:8
client_recent_max_output_buffer:0
blocked_clients:0
tracking_clients:0
clients_in_timeout_table:0
OS File-Descriptor (FD) Limits
Increasing the maximum connection count is bounded by the operating system’s file-descriptor limit. You should confirm the OS file-descriptor limit first, adjust it to an appropriate value, and only then raise Redis’s maxclients.
The OS limits on file descriptors come in two dimensions—system-level and process-level—for a total of three layers:
| Layer | Setting | Scope | Default | Adjustable |
|---|---|---|---|---|
| 1. System-wide ceiling | fs.file-max | Total FDs across all processes in the system | Hundreds of thousands ~ hundreds of millions | ✅ |
| 2. Process hard limit | ulimit -Hn | Max FDs a single process may open | Usually 65536 | ✅ (root) |
| 3. Process soft limit | ulimit -Sn | Currently effective FD limit | Usually 1024 | ✅ (≤ hard) |
View the system-wide limit fs.file-max, which is the maximum total number of FDs the whole system can allocate (the ceiling on FDs all processes may open):
postgres@slpc: sysctl fs.file-max
fs.file-max = 9223372036854775807
postgres@slpc:/etc$ sudo sysctl -a | grep -E "file|fs.nr_open"
fs.file-max = 9223372036854775807 # system-wide max FDs
fs.file-nr = 7776 0 9223372036854775807 # allocated / used / max file descriptors
fs.nr_open = 1048576 # max FDs for a single process
Raise the system-wide limit:
# Edit /etc/sysctl.conf
echo 'fs.file-max = 2097152' >> /etc/sysctl.conf
# Apply immediately
sysctl -p
Process-level limit:
Modify the process-level limit through a systemd drop-in file, /etc/systemd/system/redis.service.d/override.conf, with the following content:
[Service]
LimitNOFILE=1048576
After creating and saving this file, run systemctl daemon-reload, then systemctl restart redis to restart the Redis service, and check the process-level limit:
postgres@slpc:/etc$ cat /proc/31011/limits | grep "Max open files"
Max open files 64032 64032 files
Theoretically a 64-bit system allows FDs up to 2^64, but in practice, limited by memory and other constraints, the number of usable FDs is capped. Memory is the most critical factor determining how many FDs you can actually support. For every open file descriptor, the kernel must maintain metadata and allocate data structures (such as struct file, struct inode, etc.), consuming a certain amount of kernel memory (non-swappable):
User space Kernel space
----------- -----------
File descriptor table struct file // context of an open file
(fd_table) ↓
struct inode // filesystem metadata
↓
struct dentry // dentry cache
↓
VFS (Virtual File System layer)
Looking at the Linux kernel source, the memory cost is roughly 1~4 KB per descriptor.
As a rule of thumb, the actual maximum number of FDs is approximately equal to available kernel memory divided by the average per-FD memory overhead.