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.
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:
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.
A simplified connection-tracking process looks like this:
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.
Conntrack is commonly involved in:
Not every packet on every Linux system necessarily uses connection tracking. Stateless rules and explicitly untracked traffic can follow different paths.
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:
| Parameter | Description |
|---|---|
nf_conntrack_count | Current number of allocated connection tracking entries |
nf_conntrack_max | Maximum 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.
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:
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.
Increasing the table limit without identifying the cause can hide a resource problem rather than solve it.
Investigate the following possibilities first.
A busy server may legitimately maintain thousands or hundreds of thousands of concurrent network flows.
Common examples include:
A sudden increase in concurrent connections can exhaust a table that previously operated normally.
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.
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:
UDP tracking entries remain until their applicable timeout expires or they are otherwise removed.
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.
Container platforms can create large numbers of network flows.
Potential contributors include:
When troubleshooting, determine whether the relevant conntrack table is host-wide or associated with a particular network namespace and inspect the actual traffic path.
Unexpected traffic can also cause connection tracking growth.
Examples include:
Do not assume that every full table is caused by an attack. Compare connection counts, source addresses, protocols, and traffic patterns before drawing conclusions.
The first diagnostic step is to measure current table usage.
Run:
cat /proc/sys/net/netfilter/nf_conntrack_count Example:
64200 This is the current number of allocated connection tracking entries.
Run:
cat /proc/sys/net/netfilter/nf_conntrack_max Example:
65536 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.
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.
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.
sudo apt update
sudo apt install conntrack On systems where the package is available through the enabled repositories:
sudo dnf install conntrack-tools 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.
Run:
sudo conntrack -S This provides kernel conntrack statistics.
Depending on the kernel and conntrack-tools version, output can include counters such as:
| Counter | Meaning |
|---|---|
insert | Successful connection-tracking insertions |
insert_failed | Failed attempts to insert entries |
drop | Packets dropped by conntrack |
early_drop | Entries removed early under pressure |
search_restart | Hash-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.
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.
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.
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.
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.
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.
If a particular client is responsible for a large number of flows, investigate:
The objective is to find the workload creating the connections, not simply to remove entries without understanding their purpose.
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:
If the error appears only during specific traffic peaks, identify which service or workload is responsible for that increase.
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.
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.
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:
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.
If applications repeatedly create unnecessary connections, improve their connection management.
Possible actions include:
Reducing unnecessary connection churn can lower conntrack pressure without increasing kernel resource limits.
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.
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.
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.
Conntrack exhaustion is especially relevant on Linux systems that forward traffic or provide networking services to other workloads.
Docker may use Linux networking and NAT rules to connect containers to external networks.
Investigate:
Useful commands include:
docker ps docker network ls For additional firewall and NAT context, review the nftables Hairpin NAT guide.
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:
Do not assume that every Kubernetes networking issue is caused by conntrack exhaustion. Confirm the kernel counters and logs first.
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.
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:
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:
Do not run this command on a production gateway merely because the conntrack count is high.
A reliable monitoring strategy helps identify table pressure before it causes packet drops.
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.
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.
Track connection counts during normal operation and peak traffic.
This helps establish a baseline and detect unusual growth.
Persistent connections, appropriate connection pooling, and sensible retry policies can reduce unnecessary connection creation.
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.
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.
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:
nf_conntrack_count and nf_conntrack_max.conntrack -S.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.
Introduction Border Gateway Protocol (BGP) is the routing protocol used to exchange network reachability information…
Introduction TCP retransmissions are an important indicator of network reliability and performance. When a Linux…
Open Shortest Path First (OSPF) is a link-state routing protocol widely used in enterprise networks…
Group Policy is one of the most important management features in Windows Server Active Directory…
Windows DNS servers play an essential role in Active Directory environments, allowing computers, servers, applications,…
Linux services are responsible for running many of the critical components that keep a server…