logo of Akmatori
13.05.2024

Fixing "nf_conntrack Table Full, Dropping Packet" Error on Linux Servers

head-image

Linux servers handle vast amounts of data daily, managed via the nf_conntrack module. This tool is crucial for tracking network connections. When overwhelmed, it results in dropped packets. To address this, we will also discuss an effective tool, Akmatori.

conntrack-error

Check Conntrack Limits

Start by assessing your current limitations. Determine the maximum connections your server can handle:

  • sysctl net.netfilter.nf_conntrack_max
  • cat /proc/sys/net/netfilter/nf_conntrack_count

These commands reveal the maximum allowable and currently tracked connections.

Increase Conntrack Limits

Often, servers reach their tracking capacity. You can increase this limit easily. For immediate adjustment:

sysctl -w net.netfilter.nf_conntrack_max=131072

To ensure the change persists, modify /etc/sysctl.conf:

net.netfilter.nf_conntrack_max = 131072

Then apply changes:

sysctl -p

Optimize Connection Settings

Optimizing timeout settings can quickly free up tracking space. Modify the settings as follows:

  • For established TCP connections:
    sysctl -w net.netfilter.nf_conntrack_tcp_timeout_established=600
    
  • For general purposes:
    sysctl -w net.netfilter.nf_conntrack_generic_timeout=120
    

Incorporate these into /etc/sysctl.conf for durability.

Manual Conntrack Cleanup

In some cases, a manual flush of the conntrack table is necessary:

conntrack -F

If you lack the conntrack tool, install it with:

sudo apt install conntrack

Analyze Network Traffic

Monitoring your network traffic is crucial. Check if the high volume of connections is normal. Tools like iftop or tcpdump will help you understand your traffic flow.

Adjust App Settings

Applications that initiate excessive connections may need configuration adjustments. Review database and HTTP session settings to reduce unnecessary loads.

Introducing Akmatori

If managing connections and load balancing is a recurring challenge, consider Akmatori, a globally distributed TCP/UDP load balancer. Akmatori efficiently distributes network traffic, reducing the burden on your nf_conntrack table and preventing packet drops. It’s an ideal solution for enhancing network performance and reliability.

Monitor Regularly

Continuous monitoring is essential. Use advanced tools like Netdata or Grafana to track system performance and make informed decisions based on trends and data.

Conclusion

Keeping your Linux server running smoothly involves proactive management of nf_conntrack settings and regular system monitoring. By integrating Akmatori into your network architecture, you can ensure more reliable connection tracking and better overall performance. Manage your server's connections effectively to prevent data loss and maintain clear communication channels.

Maximize your website or application's performance and reliability!