sysctl.si › Parameters › net.netfilter.nf_conntrack_max
net.netfilter.nf_conntrack_max
Size of the connection tracking table. Full tables drop packets.
- Default
- varies with RAM
- Typical value
- About 16k per GB
When to change it
Raise it if the kernel log shows nf_conntrack table full. Each entry uses memory, so size it to your RAM.
How it works
Connection tracking lets the kernel firewall remember each connection, which NAT, Docker and Kubernetes rely on. net.netfilter.nf_conntrack_max is the largest number of connections the table can hold.
When the table is full, new connections are dropped and the kernel log shows nf_conntrack: table full, dropping packet. Idle established TCP connections stay in the table for five days by default.
Signs you need to change it
- The log shows nf_conntrack: table full, dropping packet.
- New connections fail on a NAT gateway or Kubernetes node while established ones keep working.
- net.netfilter.nf_conntrack_count is close to nf_conntrack_max.
Recommended values by workload
- Small router or server
- The default is usually enough
- Container host
- About 16384 per GB of RAM, at least 262144
- Busy NAT gateway
- 1048576 or more, sized to your RAM
Common mistakes
- Raising the limit without enough RAM. Each entry uses memory.
- Not shortening net.netfilter.nf_conntrack_tcp_timeout_established, which defaults to 432000 seconds and keeps dead connections around.
- Setting it before the nf_conntrack module is loaded, which makes sysctl report an error.
Check the current value
sysctl net.netfilter.nf_conntrack_max
Change it until the next reboot
sudo sysctl -w net.netfilter.nf_conntrack_max=VALUE
Replace VALUE with the number that fits your server. The generator can size it for you.
Make it permanent
echo "net.netfilter.nf_conntrack_max = VALUE" | sudo tee /etc/sysctl.d/99-custom.conf sudo sysctl --system
Related parameters
net.core.somaxconn · net.ipv4.tcp_max_syn_backlog · net.core.netdev_max_backlog · net.core.rmem_max · net.core.wmem_max · net.ipv4.tcp_congestion_control · net.core.default_qdisc · net.ipv4.tcp_tw_reuse
Generate a full sysctl config for your server
Values are starting points. Test on a staging machine and measure before and after.