Linux Conntrack Table Full: Diagnose and Fix nf_conntrack Packet Drops

Linux Conntrack Table Full: Diagnose and Fix nf_conntrack Packet Drops

Introduction

A Linux server can experience connection failures even when its network interface is working correctly and its firewall rules appear normal.

One possible cause is connection tracking table exhaustion.

When the Linux Netfilter connection tracking subsystem reaches its configured limit, the kernel may log:

nf_conntrack: table full, dropping packet

This means the kernel cannot allocate additional connection tracking entries because the table has reached its maximum capacity. New connections that require tracking may fail, causing symptoms such as unsuccessful connections, intermittent application errors, and dropped packets.

The problem is particularly important on Linux systems performing Network Address Translation (NAT), running stateful firewalls, hosting containers, or handling a large number of concurrent connections.

This guide explains how Linux conntrack works, how to identify table exhaustion, how to investigate the connections consuming resources, and how to increase capacity safely when necessary.

1. What Is Linux Connection Tracking (Conntrack)?

Connection tracking, commonly called conntrack, is a Netfilter subsystem that maintains information about network flows passing through the Linux networking stack.

Instead of evaluating every packet as an unrelated event, conntrack associates packets with tracked connections.

It maintains information such as:

  • Source and destination IP addresses.
  • Source and destination ports.
  • Transport protocol.
  • Connection state.
  • NAT-related information when applicable.
  • Connection timeout information.

For example, when a client establishes a TCP connection through a Linux firewall, conntrack can record the flow and recognize subsequent packets as belonging to that connection.

This allows stateful firewall rules to distinguish between new connections and packets belonging to existing connections.

How conntrack works

A simplified connection-tracking process looks like this:

  1. A packet arrives at a Netfilter hook.
  2. The kernel checks whether the packet belongs to an existing tracked flow.
  3. If it is a new flow, conntrack attempts to create an entry.
  4. The connection information is maintained while the flow remains active or until its tracking timeout expires.
  5. When the connection expires or is removed, its tracking entry is released.

A tracked flow can be used by firewall rules, NAT, and other Netfilter components.

The Linux kernel documentation provides the official reference for Netfilter connection tracking.

Where conntrack is used

Conntrack is commonly involved in:

  • Stateful iptables firewalls.
  • nftables stateful firewall rules.
  • Source NAT and destination NAT.
  • Linux routers and gateways.
  • Docker networking.
  • Kubernetes node networking.
  • VPN and network gateway infrastructure.

Not every packet on every Linux system necessarily uses connection tracking. Stateless rules and explicitly untracked traffic can follow different paths.

2. What Does nf_conntrack: Table Full Mean?

The error:

nf_conntrack: table full, dropping packet

indicates that the connection tracking table has reached its configured capacity and the kernel cannot allocate another required entry.

Two important kernel parameters help explain this condition:

ParameterDescription
nf_conntrack_countCurrent number of allocated connection tracking entries
nf_conntrack_maxMaximum number of connection tracking entries allowed

When the current count approaches the configured maximum, the system has little remaining capacity for additional tracked connections.

For example:

nf_conntrack_count = 65500
nf_conntrack_max   = 65536

The table is almost full. If the workload creates additional tracked connections, allocation failures and packet drops may occur.

These numbers are illustrative, not recommended production settings.

Why table exhaustion affects network traffic

A stateful firewall needs connection tracking information to evaluate packets correctly.

When the table cannot accommodate additional tracked flows, new connections may not be tracked successfully.

Depending on the packet path and firewall configuration, this can cause:

  • New TCP connections to fail.
  • DNS or UDP transactions to become unreliable.
  • NAT connections to fail.
  • Container-to-external-service connectivity problems.
  • Intermittent application timeouts.

Existing tracked connections may continue to work, but this is not guaranteed in every situation.

The precise impact depends on the traffic path and firewall rules.

3. Common Causes of Conntrack Table Exhaustion

Increasing the table limit without identifying the cause can hide a resource problem rather than solve it.

Investigate the following possibilities first.

3.1 High numbers of concurrent connections

A busy server may legitimately maintain thousands or hundreds of thousands of concurrent network flows.

Common examples include:

  • Reverse proxies.
  • Web servers.
  • API gateways.
  • NAT gateways.
  • Database connection pools.
  • High-traffic application servers.

A sudden increase in concurrent connections can exhaust a table that previously operated normally.

3.2 Excessive short-lived connections

Applications that repeatedly create new TCP connections can generate substantial conntrack activity.

For example, an application that opens a new database or HTTP connection for every request may create more tracking entries than an application using persistent connections and connection pooling.

Review application behavior before changing kernel limits.

3.3 UDP connection accumulation

UDP is connectionless at the transport protocol level, but conntrack can still track UDP flows using timeout-based state.

A large number of UDP flows can consume table capacity.

Possible sources include:

  • DNS traffic.
  • VoIP applications.
  • Streaming services.
  • Monitoring systems.
  • High-volume UDP clients.

UDP tracking entries remain until their applicable timeout expires or they are otherwise removed.

3.4 NAT gateway traffic

Linux systems performing NAT may track traffic for many internal clients.

For example, a gateway serving hundreds of workstations may maintain a large number of simultaneous connections to external services.

The total number of flows can grow rapidly when clients generate many short-lived connections.

3.5 Container and Kubernetes workloads

Container platforms can create large numbers of network flows.

Potential contributors include:

  • Many containers sharing a host.
  • Frequent service-to-service connections.
  • High DNS request volumes.
  • Container restarts and connection churn.
  • Node-level NAT and forwarding.

When troubleshooting, determine whether the relevant conntrack table is host-wide or associated with a particular network namespace and inspect the actual traffic path.

3.6 Scanning, abuse, or abnormal traffic

Unexpected traffic can also cause connection tracking growth.

Examples include:

  • Port scans.
  • Connection floods.
  • Misbehaving clients.
  • Automated retry loops.
  • Unintended traffic amplification.

Do not assume that every full table is caused by an attack. Compare connection counts, source addresses, protocols, and traffic patterns before drawing conclusions.

4. Check nf_conntrack_count and nf_conntrack_max

The first diagnostic step is to measure current table usage.

Check the current number of tracked entries

Run:

cat /proc/sys/net/netfilter/nf_conntrack_count

Example:

64200

This is the current number of allocated connection tracking entries.

Check the configured maximum

Run:

cat /proc/sys/net/netfilter/nf_conntrack_max

Example:

65536

Calculate table utilization

You can calculate utilization with:

count=$(cat /proc/sys/net/netfilter/nf_conntrack_count)
max=$(cat /proc/sys/net/netfilter/nf_conntrack_max)

awk -v count="$count" -v max="$max" \
'BEGIN {
    if (max > 0)
        printf "Conntrack usage: %.2f%% (%d / %d)\n",
        (count / max) * 100, count, max
}'

Example output:

Conntrack usage: 97.96% (64200 / 65536)

This indicates that the table is operating close to its configured limit.

Monitor usage continuously

Use:

watch -n 2 '
echo "Current:"
cat /proc/sys/net/netfilter/nf_conntrack_count
echo "Maximum:"
cat /proc/sys/net/netfilter/nf_conntrack_max
'

This refreshes the values every two seconds.

Observe whether usage remains consistently high or increases rapidly during traffic peaks.

A temporary spike and sustained table exhaustion require different investigations.

5. Monitor Conntrack with the conntrack Command

The conntrack utility is part of the conntrack-tools package. It provides a userspace interface for inspecting tracked connections and kernel statistics.

Install it if it is not already available.

Debian and Ubuntu

sudo apt update
sudo apt install conntrack

RHEL, Rocky Linux, and AlmaLinux

On systems where the package is available through the enabled repositories:

sudo dnf install conntrack-tools

Display the number of tracked connections

Run:

sudo conntrack -C

This displays the current connection tracking table count.

Compare it with the kernel’s nf_conntrack_count value when investigating capacity issues.

Display connection tracking statistics

Run:

sudo conntrack -S

This provides kernel conntrack statistics.

Depending on the kernel and conntrack-tools version, output can include counters such as:

CounterMeaning
insertSuccessful connection-tracking insertions
insert_failedFailed attempts to insert entries
dropPackets dropped by conntrack
early_dropEntries removed early under pressure
search_restartHash-table search restart events

An increasing insert_failed or drop counter during an incident is important evidence.

Counter availability and interpretation can vary by kernel version.

List tracked connections

Run:

sudo conntrack -L

This lists tracked flows.

For a large production table, avoid dumping the entire table repeatedly. The output can be extremely large and consume significant processing time.

Filter by protocol where appropriate:

sudo conntrack -L -p tcp

Or inspect UDP flows:

sudo conntrack -L -p udp

You can also filter by source address:

sudo conntrack -L -s 192.168.1.50

Replace the example address with the actual client IP.

Monitor connection events

To observe new and updated conntrack events:

sudo conntrack -E

This is useful for understanding connection churn during an incident.

Use filters when possible to avoid producing excessive output on busy systems.

The official conntrack-tools manual documents listing, counting, monitoring, statistics, and other operations.

6. Identify Which Connections Consume the Table

Finding a high connection count is only the beginning. The next step is determining which clients, protocols, or applications contribute most of the tracked flows.

Inspect connection sources

A quick way to summarize source addresses from a conntrack listing is:

sudo conntrack -L -o extended 2>/dev/null |
awk '{
    for (i = 1; i <= NF; i++) {
        if ($i ~ /^src=/) {
            sub(/^src=/, "", $i)
            print $i
            break
        }
    }
}' |
sort |
uniq -c |
sort -nr |
head -20

This provides a rough source-address summary.

Important: Conntrack output contains both original and reply-direction information. The first src= field is not necessarily the original client in every traffic scenario. Interpret the results in the context of your network and NAT configuration.

Identify TCP and UDP distribution

You can count protocol entries with:

sudo conntrack -L 2>/dev/null |
awk '{
    for (i = 1; i <= NF; i++) {
        if ($i == "tcp" || $i == "udp" || $i == "icmp") {
            print $i
            break
        }
    }
}' |
sort |
uniq -c |
sort -nr

This is a basic summary and may need adjustment for other protocols or different output formats.

Investigate repeated connection creation

If a particular client is responsible for a large number of flows, investigate:

  • Application connection pooling.
  • HTTP keep-alive configuration.
  • Database connection reuse.
  • DNS request volume.
  • Automated retry behavior.
  • Unexpected client traffic.

The objective is to find the workload creating the connections, not simply to remove entries without understanding their purpose.

7. Diagnose Conntrack Errors in Kernel Logs

Kernel logs can confirm whether table exhaustion is occurring.

Search recent kernel messages:

sudo journalctl -k --since "30 minutes ago" |
grep -iE 'conntrack|table full|dropping packet'

On systems that use dmesg, you can also run:

sudo dmesg -T | grep -i conntrack

Look for messages such as:

nf_conntrack: table full, dropping packet

Correlate the timestamps with:

  • Application errors.
  • Firewall logs.
  • Traffic peaks.
  • Conntrack utilization.
  • Container or service restarts.

If the error appears only during specific traffic peaks, identify which service or workload is responsible for that increase.

8. Fix Conntrack Table Exhaustion Safely

There is no single solution for every conntrack problem.

The appropriate fix depends on whether the table is too small for a legitimate workload, whether connections are accumulating unnecessarily, or whether unexpected traffic is creating excessive state.

8.1 Increase nf_conntrack_max

If the workload legitimately requires more concurrent tracked connections and the host has sufficient memory, increasing the maximum may be appropriate.

First inspect the current values:

sysctl net.netfilter.nf_conntrack_count
sysctl net.netfilter.nf_conntrack_max
sysctl net.netfilter.nf_conntrack_buckets

The nf_conntrack_count parameter is read-only.

The nf_conntrack_max parameter controls the maximum number of entries.

For a temporary change, use a carefully selected value:

sudo sysctl -w net.netfilter.nf_conntrack_max=131072

The value 131072 is an example, not a universal recommendation.

After changing the value, verify it:

sysctl net.netfilter.nf_conntrack_max

Then monitor table utilization and memory usage under normal peak traffic.

8.2 Understand conntrack memory requirements

Increasing the table limit increases the potential memory consumed by connection tracking.

The actual memory requirement depends on kernel version, architecture, enabled extensions, and workload characteristics.

Before increasing the limit, inspect memory availability:

free -h

You can also inspect slab memory:

sudo slabtop

Look for conntrack-related allocations, such as nf_conntrack where exposed by the kernel.

Do not choose a large maximum based only on the number of CPU cores or a generic online recommendation.

Capacity planning should consider:

  • Expected concurrent connections.
  • Peak connection churn.
  • Available RAM.
  • Other kernel memory consumers.
  • Firewall and NAT workload.
  • Operational safety margin.

8.3 Review connection timeouts

Conntrack entries remain allocated according to protocol-specific state and timeout behavior.

For example, inspect common timeout parameters:

sysctl net.netfilter.nf_conntrack_tcp_timeout_established
sysctl net.netfilter.nf_conntrack_tcp_timeout_time_wait
sysctl net.netfilter.nf_conntrack_udp_timeout
sysctl net.netfilter.nf_conntrack_udp_timeout_stream

A long timeout can retain inactive entries longer.

However, reducing timeouts indiscriminately can disrupt legitimate connections, NAT mappings, or applications with long idle periods.

Only adjust a timeout when measurements show that the existing value is inappropriate for the workload.

8.4 Fix application connection churn

If applications repeatedly create unnecessary connections, improve their connection management.

Possible actions include:

  • Enable HTTP keep-alive where appropriate.
  • Configure database connection pooling.
  • Reuse persistent connections.
  • Correct aggressive retry loops.
  • Review client-side timeout and retry policies.
  • Investigate abnormal connection creation.

Reducing unnecessary connection churn can lower conntrack pressure without increasing kernel resource limits.

8.5 Investigate abnormal traffic

If a small number of sources create a disproportionate number of tracked connections, investigate their behavior.

Check firewall logs, traffic captures, application logs, and connection statistics.

If the traffic is malicious or unwanted, use an appropriate firewall policy or upstream mitigation strategy.

Avoid blocking legitimate clients based only on a high connection count.

9. Configure Persistent Conntrack Settings with sysctl

Changes made with sysctl -w are generally runtime changes. They may not survive a reboot.

To make a justified setting persistent, create a dedicated configuration file.

For example:

sudo nano /etc/sysctl.d/99-conntrack.conf

Add:

net.netfilter.nf_conntrack_max = 131072

Save the file and apply it:

sudo sysctl --system

Verify the active setting:

sysctl net.netfilter.nf_conntrack_max

The example maximum must be selected according to the server’s actual workload and memory capacity.

Verify the conntrack module

On systems where conntrack is provided as a loadable kernel module, inspect whether it is loaded:

lsmod | grep nf_conntrack

You can also inspect the sysctl directory:

ls /proc/sys/net/netfilter/

The exact module and parameter availability depends on the kernel configuration and distribution.

Do not blindly add module-loading commands or modify boot configuration without confirming how the distribution loads Netfilter modules.

10. Conntrack Troubleshooting in Docker, NAT and Firewalls

Conntrack exhaustion is especially relevant on Linux systems that forward traffic or provide networking services to other workloads.

Docker networking

Docker may use Linux networking and NAT rules to connect containers to external networks.

Investigate:

  • The number of active containers.
  • Container connection patterns.
  • Published ports.
  • Repeated DNS requests.
  • Host-level conntrack utilization.

Useful commands include:

docker ps
docker network ls

For additional firewall and NAT context, review the nftables Hairpin NAT guide.

Kubernetes nodes

Kubernetes nodes can handle traffic from many pods and services.

A large number of short-lived connections, service traffic, and node-level NAT operations can increase conntrack usage.

Investigate:

  • Pod connection patterns.
  • DNS traffic.
  • Node-level packet forwarding.
  • CNI networking behavior.
  • Conntrack statistics on affected nodes.

Do not assume that every Kubernetes networking issue is caused by conntrack exhaustion. Confirm the kernel counters and logs first.

Linux NAT gateways

A Linux NAT gateway can track connections from many internal clients.

Monitor the gateway’s table utilization during peak hours and compare it with traffic volume.

If the table is consistently close to its limit, determine whether the increase is caused by legitimate concurrent sessions, excessive connection churn, or unwanted traffic.

Stateful firewalls

nftables and iptables can use conntrack state to implement stateful filtering.

For example, a typical nftables rule may accept established and related traffic:

ct state established,related accept

This rule relies on connection-tracking state.

Increasing nf_conntrack_max does not automatically fix incorrect firewall rules, NAT configuration, or packet-filtering problems.

For firewall configuration details, see:

11. Should You Flush the Conntrack Table?

A common reaction to conntrack exhaustion is to run:

sudo conntrack -F

This flushes the connection tracking table.

It is not a recommended routine fix.

Flushing the table removes tracking state for existing flows. This can interrupt active connections and disrupt NAT behavior.

It may temporarily reduce table usage, but it does not solve the underlying reason for excessive connection tracking.

Before considering a flush:

  1. Confirm the table is actually exhausted.
  2. Identify the affected services and network paths.
  3. Evaluate the impact on active connections.
  4. Prefer targeted remediation where possible.
  5. Schedule disruptive maintenance if a full flush is genuinely necessary.

Do not run this command on a production gateway merely because the conntrack count is high.

12. Monitoring and Prevention Best Practices

A reliable monitoring strategy helps identify table pressure before it causes packet drops.

Monitor utilization percentage

Collect both:

nf_conntrack_count
nf_conntrack_max

Calculate the utilization percentage periodically.

Alert thresholds should be based on workload behavior and available capacity, not a universal percentage that applies to every server.

Monitor kernel drop counters

Collect:

sudo conntrack -S

Pay attention to changes in insert_failed and drop counters.

A rising counter during a period of high utilization is a strong reason to investigate.

Monitor connection growth

Track connection counts during normal operation and peak traffic.

This helps establish a baseline and detect unusual growth.

Review application connection management

Persistent connections, appropriate connection pooling, and sensible retry policies can reduce unnecessary connection creation.

Plan capacity before traffic increases

For gateways, firewalls, and container hosts, estimate expected concurrent flows and test the system under realistic peak workloads.

Include memory consumption and kernel configuration in capacity planning.

Keep kernel and networking tools maintained

Use supported kernel versions and updated networking utilities.

Kernel and conntrack-tools versions can differ in available counters, parameters, and output formats.

Always verify the documentation for the version running on the affected server.

Conclusion

The Linux error nf_conntrack: table full, dropping packet indicates that the connection tracking subsystem has reached its configured capacity.

It can cause new connections to fail and create intermittent connectivity problems on Linux firewalls, NAT gateways, container hosts, and busy application servers.

A reliable troubleshooting process should:

  1. Check nf_conntrack_count and nf_conntrack_max.
  2. Monitor usage and kernel logs.
  3. Inspect conntrack statistics with conntrack -S.
  4. Identify the sources and protocols generating tracked flows.
  5. Review application connection behavior and timeout settings.
  6. Increase the table limit only when capacity planning supports it.
  7. Monitor the system after applying changes.

The goal is not simply to make the conntrack table larger. It is to understand why connection-tracking demand is growing and ensure that the Linux server has sufficient resources to handle its actual workload.

Leave a Reply

Your email address will not be published. Required fields are marked *