Featured image of post Fix Redis TCP Backlog 511 Warning: Raise somaxconn

Fix Redis TCP Backlog 511 Warning: Raise somaxconn

Redis warns that TCP backlog 511 exceeds somaxconn 128, dropping connections under load. Raise somaxconn via /proc and persist it in sysctl.conf permanently.

Problem

When starting Redis, this warning appears:

1
2
The TCP backlog setting of 511 cannot be enforced because
/proc/sys/net/core/somaxconn is set to the lower value of 128

Redis defaults to a TCP backlog of 511, but the Linux kernel’s somaxconn is only 128, so Redis can’t use the queue length it wants. Under heavy connection load, this can cause dropped connections.

TCP backlog limited by somaxconn

Solution

Increase somaxconn with root privileges:

1
echo 512 > /proc/sys/net/core/somaxconn

This won’t persist after a reboot. To make it permanent, add the setting to /etc/sysctl.conf:

1
net.core.somaxconn=512

Then reboot or run sysctl -p to apply.